Thursday, June 5, 2008

Thousand words and more

I thought looking at the results of Google Image search for a few 'abstract' words would be interesting. So I wrote a screen scraping script in Ruby (this language is just great - the force is definitely deep with this one) that reads in search terms from a file and collects the searched images and their links from the first page of the image search results. The images were subsequently resized using ImageMagick. My list was:

Always, Bliss, Blossom, Blue, Bubble, Death, Delirium, Destiny, Dreams, Eternity, Fantastic, Happiness, Hilarious, Hope, If, Liberty, Life, Love, Nothingness, Rainbow, Smile, Sunflower, Sunshine, Time

And below are some of the results. The images are clickable - they lead you to the www links Google obtained them from. Note that Google returns 21 search results(images) on its first page in its default setting. In some cases I could'nt retrieve the images due to various technical snags that I was too lazy to spare any attention for. I am just putting up 5 or less per search word, in no particular order - ones that appeal to me or stand out in some way (and post censoring :) ) - you could ask me if I were a tyrant and I would say 42. So lets just get going:



Always:






Bliss:






Blossom:






Blue:






Bubble:







Death:






Delirium:







Destiny:






Dreams:






Eternity:






Fantastic:






Happiness:






Hilarious:






Hope:






If:






Liberty:






Life:






Love:






Nothingness:






Rainbow:






Smile:






Sunflower:






Sunshine:






Time:






And, finally, on a lighter note, can you believe Google turned up this while searching for 'bubble'?:

Saturday, April 19, 2008

Alphabot

A friend of mine had put a this link up in Google Talk status message:

http://playfreeonlinegames.eu/playonline/typethealphabet.html

and his record of 2.84 seconds. In an exhausted state, after having spent a day running after some compatibility issue in some code, my first shot earned me 6.89 seconds.

Huh?!


Deciding to take matters a wee bit more seriously I decided to ... umm... cheat. I wrote this Java code:

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class alphabot {

public static void main(String[] args) {

try {

Robot robot = new Robot();

robot.delay(5000);

robot.keyPress(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_B);
robot.keyPress(KeyEvent.VK_C);
robot.keyPress(KeyEvent.VK_D);
robot.keyPress(KeyEvent.VK_E);
robot.keyPress(KeyEvent.VK_F);
robot.keyPress(KeyEvent.VK_G);
robot.keyPress(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_J);
robot.keyPress(KeyEvent.VK_K);
robot.keyPress(KeyEvent.VK_L);
robot.keyPress(KeyEvent.VK_M);
robot.keyPress(KeyEvent.VK_N);
robot.keyPress(KeyEvent.VK_O);
robot.keyPress(KeyEvent.VK_P);
robot.keyPress(KeyEvent.VK_Q);
robot.keyPress(KeyEvent.VK_R);
robot.keyPress(KeyEvent.VK_S);
robot.keyPress(KeyEvent.VK_T);
robot.keyPress(KeyEvent.VK_U);
robot.keyPress(KeyEvent.VK_V);
robot.keyPress(KeyEvent.VK_W);
robot.keyPress(KeyEvent.VK_X);
robot.keyPress(KeyEvent.VK_Y);
robot.keyPress(KeyEvent.VK_Z);




} catch (AWTException e) {
e.printStackTrace();
}
}
}



This is an awt robot which can be given the control of your mouse and keyboard. This particular one waits for 5 seconds to let you click or focus your mouse someplace, and then "types" in the letters of the English alphabet.

I compiled it and ran it (as such things go), and before my 5 seconds were up, went to the Webpage to click on 'a' and wait. And , lo! 0.03 secs. Not bad at all ...


This is where I should have ideally finished my post and not written this statement and the few that follow it had I not remembered a puzzle I recently read:

Place 50 balls in 9 boxes so that each box contains an odd number of balls.

At first glance this seems impossible since the sum of an odd number of odd integers cannot be even. Its, however, achievable if you place a box inside another. Talk about a puzzle that forces you to think outside the box to only lead you back to inside one.

Yawn!

Tuesday, March 11, 2008

Binary Sudoku


After a busy day, while I was way into a hectic night , I came across this. I really was in no mood to be humored, but then I looked away and chuckled. Hilarious!


(The above pic is from http://xkcd.com/74/)

Monday, January 21, 2008

Coffeeproof

Coffee doesn't affect me anymore - this is not a recent discovery, of course, but people around me who are discovering it find it very surprising - and I find that amusing. So when I drink coffee these days its more like a force of habit (when its 'normal' coffee) or a whim of indulgence (if you happen to spot me in a Barista/Cafe Coffe Day/Qwiky) - never, anymore to stay up in the nights, since I can make it to the deep slumber zone after a mega mug with consistent success, in a couple of minutes flat, effectively competing with the well advertised 2-minute Maggi preparation time. Thats a hard earned skill too - came about after repetitive coffee hogging many times a day when I was working as a software developer, or the many times a week outside my office when I would walk into one of those coffee outlets with a novel in my hand, in a pitted battle against ennui clawing at my life.

And so there was this time, when one of my roomies was leaving for good, and we decided to stay awake and chat till late in the night - and they decided that downing a few dregs of the strongest coffee would facilitate that (I was smirking inwardly). So we go to a Cafe Coffee Day, we return, and while they begin their anticipated chat session, I leave them to gape at me as my lights go out almost instantaneously after I lie down for a while.

And while I am here about coffee, heres a Turkish proverb in context:

"Coffee should be black as hell, strong as death and sweet as
love."

(Not that even that would work for me ... )

Monday, June 25, 2007

Jonathan Strange and Mr. Norrell (quotes)

I recently had the oppurtunity to read the novel "Jonathan Strange and Mr. Norrell" by Susanna Clarke. The favorable reviews and the fact that this won the Mythopoeic Fantasy Award (for Adult Literature) apart, I decided to read it because I just cannot keep off fantasy books - talk of sorcery, magic, swords and dragons, and I am in. Another old habit that would die hard, if at all.

Susanna Clarke chooses a style of writing thats in line with the backdrop of the book : the novel is set in the England of 1800, and is about the attempts of two magicians to restore English magic to its former glory. Small surprise then that "old" period English is used- with words like Shewed (showed), Stopt (stopped), Scissars (scissors), Expence (expense), Headach (headache) making a liberal presence.

Much of the novel carries itself at a leisurely pace, punctuated with a fair share of thrilling moments. The author has a gift of prose that stands to her advantage in a novel like this, serving to create a much needed atmosphere of casual magic. And, of course, there are places where Clarke’s prose additionally decorates the story, bringing to life the parts that are meant to stand out.

Some of my most memorable lines from the novel are:

(1)
Childermass was one of those uncomfortable class of men whose birth is lowly and who are destined all their lives to serve their betters, but whose clever brains and quick abilities make them wish for recognition and rewards far beyond their reach. Sometimes, by some strange combination of happy circumstances, these men find their own path to greatness, but more often the thought of what might have been turns them sour; they become unwilling servants and perform their tasks no better - or worse – than their less able fellows. They become insolent, lose their places and end badly.

(2)
After two hours it stopped raining and in the same moment the spell broke, which Peroquet and the Admiral and Captain Jumeau knew by a curious twist of their senses, as if they had tasted a string quartet, or been, for a moment, deafened by the sight of colour blue.

(3)
She was always very ready to smile and, since a smile is the most becoming ornament that any lady can wear, she had been known on occasion to outshine women who were acknowledged beauties in three counties.

(4)
Under other circumstances she would have been puzzled to know what to say to a man of the world like Jonathan Strange, but happily his father had just died and that provided a subject.

(5)
“Can a magician kill a man by magic?” Lord Wellington asked Strange. Strange frowned. He seemed to dislike the question. “I suppose a magician might,” he admitted, “but a gentleman never could.”

(6)
“All of Man’s works, all his cities, all his empires, all his monuments will one day crumble to dust. Even the houses of my own dear readers must – though it be for just one day, one hour – be ruined and become houses where the stones are mortared with moonlight, windowed with starlight and furnished with the dusty wind. It is said in that day, in that hour, our houses will become possessions of the Raven King…”

(7)
“… I am rather of the opinion that in England a gentleman’s dreams are his own private concern. I fancy there is a law to that effect and, if there is not, why, Parliament should certainly be made to pass one immediately! It ill becomes another man to invite himself into them.”

(8)
“… Soldiers, I am sorry to say, steal everything.” He thought for a moment and then added, “Or at least ours do.”

(9)
“… The French mayn’t pass here. Why, sir! A beetle mayn’t pass unless that beetle has a paper with Lord Wellington’s writing on it!...”

(10)
But from the first moment of his entering the house Strange found himself subject to that peculiarly uncomfortable Natural Law which states that whenever a person arrives at a place where he is not known, then wherever he stands he is sure to be in the way.

(11)
“My admiration does not lessen my hatred one whit!”

(12)
“Well, I suppose one ought not to employ a magician and then complain that he does not behave like other people,” said Wellington.

(13)
“Dear God!!” cried Fitzroy Somerset, “What language is that?”
“I believe it is one of the dialects of Hell,” said Strange.
“Is it indeed?” said Somerset. “Well, that is remarkable.”
“They have learnt it very quickly,” said Lord Wellington, “They have been dead only three days.” He approved of people doing things promptly and in a businesslike fashion.

(14)
All magicians lie and this one more than most, Vinculus had said.

(15)
“Means?” said Stephen. “That is an odd word to use. Yet it is true – skin can mean a great deal. Mine means that any man can strike me in a public place and never fear the consequences. It means that my friends do not always like to be seen with me in the street. It means that no matter how many books I read, or languages I master, I will never be anything but a curiosity – like a talking pig or a mathematical horse.”

(16)
“It is these black clothes,” said Strange. “I am like a leftover piece of funeral, condemned to walk about the Town, frightening people into thinking of their own mortality.”

(17)
Most of us are naturally inclined to struggle against the restrictions our friends and family impose upon us, but if we are so unfortunate as to lose a loved one, what a difference then! Then the restriction becomes a sacred trust.

(18)
“We will know them as we know other men,” he declared, “by the fruits they bear.”

(19)
The sunlight was cold and clear as the note struck by a knife on a fine wine-glass.

(20)
Though all the houses of Venice are strange and old, those of the Ghetto seemed particularly so – as if queerness and ancientness were two of the commodities this mercantile people dealt in and they had constructed their houses out of them. Though all streets of Venice are melancholy, these streets had a melancholy that was quite distinct – as if Jewish sadness and Gentile sadness were made up according to different recipes.

(21)
“…With the ashes that were her screams and the pearls that were her bones and the counterpane that was her gown and the magical essence of her kiss, I was able to divine your name - …”

(22)
These are the customary three elements of a traditional English summoning spell. The envoy finds the person summoned, the path brings him to the summoner and the handsel (or gift) binds him to come. (I like this one because this represents sound communication principles :) - AG)

(23)
The ashes, the pearls, the counterpane and the kiss.



Of these, the last one – “Ashes, Pearls, the Counterpane and the Kiss”- appeals to me the most. This is the title of a chapter in the book. In which, the Elf-king of the Kingdom Of Lost Hope proudly regales Stephen (a character whom the Elf King admires a lot) with an account of his investigations carried out to find out Stephens' original name . The King is a misanthrope, and Stephen discovers much to his horror, but sadly not to his surprise, that the kings' quest, funded with his hatred for mankind, has woven a wake of innocent deaths.

A cursory glance at the words, hint at a romantic allusion ( or at any rate a positive/beautiful feeling), but a moment's thought sets them into their proper context and brings to mind the deaths so casually scribed by their speaker. Apparently for his love (of Stephen): a cause much ill justified for the price it has entailed. In effect, to me,they are almost like a painfully beautiful picture on a wall that hides an ugly gash underneath. Or like a simulacrum of the many contrasts of life itself.

Thursday, June 7, 2007

Thoughts during coffee

I am thinking these thoughts as I have my coffee in the office canteen on an evening. Incomplete thoughts that stay but a moment (and give me enough reason to post) :

(1) The news declares that inflation is down at 5.06%. I start thinking of things that have usually been known (or are expected) to show an upward trend. Inflation? No. Population... hmm..probably in India. Entropy/chaos - yes. Entropy seems such an intangible concept. I wonder whether it can be correlated to a "materialistic" quantity. Say, if I land upon earth 500 years hence, would I be able to remark that the entropy of the universe has increased by
k.(p)^α , where p = population of the SomeCountry ??

We know that entropy increases. Does the rate of its increase increase? How about the rate of rate of rate its increase? Does the universe have a limit to the number of times you can say "rate of " before the final "rate" becomes a constant?

Interesting question thats pops up in my mind - suppose I had 'x' number of men and 'x' number of women to start with. And I mandate that every couple has one child. I also assume that the society is monoandrous and monogamous. So the next generation has x/2 people, the next has x/4 ... and the population dies out eventually? Why would some governments want that - ha!

(2) The last few days have been easy for me (at office)

(3) The furniture, the lighting around, the various counters in the canteen are not unlike other canteens/joints that I see these days. Things have become so impersonally utilatirian that it is difficult to note the "personality" of something expressed in its existence. Like the Irani coffeehouses in Mumbai. One CCD (cafe Coffee Day) outlet is same as others. Good or bad?

(4) The canteen used to have an interesting arrangement of water coolers previously. By a wall, they had a table on which fresh glasses were placed. A water cooler sat to its right. Another water cooler sat to the right of the first one. And finally, we had another table with fresh glasses placed on it. The arrangement may be pictured as below:

1st table with glasses -- water cooler -- water cooler -- 2nd table with glasses

I had often wondered whther I could roughly estimate the no. of left handed people in the office by counting the glasses used from the first table. But, then there would be so much 'noise' in the (hypothetical) experiment:
(a) Used glasses are replaced with fresh ones periodically
(b) During peak hours people choose to drink from a particular cooler based on the queue in
front of it.
(c) I dont know whether everyone comes to the canteen for food

(5) Mamihlapinatapai- beautiful Yaghan word, meaning

"a look shared by two people with each wishing that the other will initiate something that both desire but which neither one wants to start "

I wonder how they missed out on it in English - a commonplace phenomenon (and a practical example of deadlocks).
Interesting the Yaghan language is considered to be a 'language isolate' i.e. a language which hasn't been proved to have descended from any other.

(6) Amruth and I were chatting the other day. I told him that 'Mamihlapinatapai', 'chathuringmes', 'Jabberwocky' were 3 unusual words that I had come across in the most unexpected of sources.

(7) Read the following lines:

You are the fairest of your sex,
Let me be your hero;
I love you as much as 1 over x,
As x tends to zero.
Positively.

The last word postively takes the cake...


End of coffee.

Monday, March 5, 2007

Orkut friends list – a few thoughts

The orkut phenomenon has really caught on with the number of its users reaching a whopping 45 million. The other day, Tanmay said its an innovation in communication (or did he say a new communication technology?) – that might be stretching it a bit too far, but then again, for an application with 45 million users I couldn’t dare to disagree (at least not there and then- but I might return with an interesting argument later :-) , the clichéd argumentative Indian that I am...).

Orkut represents an interesting aspect of the general “ambivertedness” of the human nature. Standing right in the middle of our desire of privacy in communication (which e-mail services provide us with – if I mail a person A, nobody else needs to know about that) and our desire for recognition. Orkut is an in-between since (a) you usually do not expect a complete stranger to scrap you (for the ladies- I used the word usually) – so there IS some amount of privacy (b) if an acquaintance happens to drop by, you want a uber-chic profile – the desire for recognition. Also you don’t mind a friend reading the scraps written to you by another friend.

The friends-list is a source for some interesting ideas. But to talk about things in a precise way lets talk about graphs first. (You can skip this paragraph if you know what they are). All we need to know for now is that a graph is a diagram like this:

Dots and lines. Graphs are of profound importance in mathematics since a lot of situations can be modeled as graphs (let the dots be cities, the lines be roads – so the above diagram can be believed to represent cities and the interconnecting roads etc.), and any theorem that’s true for the graphs can be carried to the original situations to gain deeper insight. We will call the dots and lines, nodes and edges respectively. Also, we say a graph is connected if you can find a path of lines/edges between any two nodes. The above graph is connected. The following one isn’t:

since there is no path between b and a.

Back to orkut now. The friends list can be modeled as a graph with nodes being people and the edges (though they do not exist materially) as “friendships”. We will call this graph the “friend-graph”.

Thoughts on the friend-graph:

[1] Orkut claims that you are connected to 45 million people (you see this message when you log in). Connected means if you pick up any 2 people amongst the users, you will always be able to find a chain of friends between them (or, a path in the friend-graph), right? Now 45 million is a big number and I was not too sure that all the users are connected. So I created a second profile only to have orkut claim that I was connected to 45 million people through 0 friends. Clearly not true – I was expecting to be told that I was connected to zero people. Or rather, let me put it in this way: orkuts’ definition of connectedness is not the same as ours. What Orkut means is you are potentially connected to 45 million users.

[2]Someone mentioned that friends list is a tree. Its not. A tree is a special kind of graph that looks like this:

It’s precisely defined as a graph that doesn’t have circuits (circuit is a path that leads to the starting point). Orkut has circuits. Noticed that “common friends” list when you visit a profile (say a friend named x)- which is supposed to show the friends that are common to the profile and you? Let’s assume a common friend is y. Visualize the orkut friend-graph now – there is an edge between you and x. And there is path with the edges: you->y, y -> x (since y is friend of x too). So we have the circuit: you->x->y->you. Thus the orkut friends list is definitely not a tree.

[3] The friend graph is also a dynamic graph i.e. one in which the number of nodes change (new users, deleted profiles) and the number of edges change (new friends)

[4] When a new user registers, the count of the total number of users does not go up immediately. Orkut changes the count periodically, not immediately.

[5] It would be interesting to know how many people you are really connected to, through chains of friends i.e. the number of nodes in he connected component of the graph you are a part of. But orkut doesn’t disclose this data :(

[6] I think it would be quite interesting to find out what is the minimum number of those crucial profiles in your connected component, which if deleted, breaks the component into two disconnected parts (and do what?)

[7] Anyone for finding out the degrees of separation? The famous Milgram experiment claimed that any 2 people in the US are separated by six acquaintances in general. That was in 1967. I would love to know what the average dergree of separation on Orkut is.

[Gaurav said he wanted something more from the article. Hence this message to the non-geeks : ignore this paragraph and the following one.


Parankush and I were actually planning to find out the degrees of separation on Orkut. The quick and dirty implementation plan was to use a screen-scraping package like PERL Mechanize, scrape all the friend-graph related data onto the local disk, and then do whatever we wish to do with the data ( like boast about it, run algos to find out the minimal cut-sets, the average degree of separation etc etc). Some interesting challenges were (a) we would need a way to merge findings from my program and his (since we were planning to run the codes over our machines, separately, and we didn’t want redundant work. (b) savepoints: to protect ourselves against power failures, and proxy server downtimes we needed a way to commit a savepoint periodically (or, detect when the laptop switches to the battery backup, so that a save point is registered automatically then) (c) how do we pack such a volume of data on our hard drives . The biggest problem however was time : we had absolutely no idea how long we would have to run our codes (days? Weeks?) to scrape all the data using our not-so-reliable net connections and other interrupting factors. Larger the amount of time required to run the algos, more a dynamic graph changes – a fact which prompted Parankush to ask me the Tao of all questions: “Why are we doing this?” As a reply to which we retired to our monotonous lives.]