HashMap sorted based on values…

June 24, 2007

Just wrote a simple HashMap class to have entries sorted based on values…i.e. the keySet() method will return the keys based on sorted order of their corresponding values…

Here it goes…

import java.util.*;
import java.util.*;
/**
* HashMap with entries sorted based on Values. (keySet() method will return keys sorted based on values.)
* @author Sumedh Inamdar
*/
public class ValueSortedHashMap extends HashMap {
  
  public Set keySet() {
    TreeSet s = new TreeSet(new MapValueComparator(this));
    s.addAll(super.keySet());
    return s;
  }
  
  /**
   * Comparator class for comparing keys based on values. Assumes that values are ‘Comparable’.
   */
  class MapValueComparator implements Comparator {
    MapValueComparator(Map m) {
      map = m;
    }
   public int compare(Object k1, Object k2) {
     if(!(map.get(k1) instanceof Comparable)) {
       System.out.println(“ERROR…ValueSortedHashMap could not compare the values…”);
       return 0;
     }
     return ((Comparable)map.get(k1)).compareTo(map.get(k2));
   }
   Map map;
  }
}

By the way…does any one know a quick way to post formatted code on site? This was pain in a$$…Blogger just removes my spaces after I do some editing…and for even adding spaces, I had to hack it like this 😦

Advertisements

India Tech Startup scene – Social Networking

June 15, 2007

For last few weeks, I was following indian tech startup scene…started by reading some excellent articles by Paul Graham and Guy Kawasaki…got particularly interested after reading a detailed report in Business Today (3rd June issue)…VC investments in India shot up from $17 million to $166 million in 2006…the scene is certainly red hot

Here is a brief summary of web 2.0 (or just web…hell with this 2.0 or 3.0 crap) companies…I will cover it categorywise…

Social Networking: MingleBox would of course be the first name coming on top…especially after getting that sumptuous sum of $7 million from Sequoia. Then there is yaari, Jhoom, Fropper, DesiMartini, Indyarocks and not sure how many more…everyone is ‘Web 2.0’ with all the latest features of sharing photos, videos, blogging, yada yada yada. Find Amit Ranjan’s (of Slideshare.net) take here. There are some who are trying to find a niche. Sixer.tv for cricket fans, or saffronconnect for music for example. It will be interesting to see who wins…there should not be more than 2 or 3 players in general category when war is over. Minglebox is tapping into the college campuses, by creating readymade college campus groups…really smart move…that will make the new generation stick on Minglebox after we all being taken by Orkut…
Orkut looks so passe with these agile newcomers…I wonder why on earth orkut was successful in India, in spite being nowhere in US…It will be interesting to see how the newcomers use mobile connectivity to a good effect. That can prove a main driver for people to switch from orkut…right now, the only reason I am active on orkut is that I have my friends there…the fundamental reason behind the term ‘critical mass’.

Don’t know if there are clones of variants like Fanpop (fan-following-social-network) or twitter (find-what-I–am-doing – the original purpose of weblog) in india…may be some people are working on those already…it doesn’t take long to have such clones these days, with internet minimizing geographical distances and spreading knowledge unbelievably fast…one more innovative venture is Ning…by Marc Andersson of Netscape fame…it allows you to create your own social network… of course it won’t be much better than creating groups inside a normal social network as of now…you won’t be able to really edit it the way you like…beyond adding a few widgets…but they will evolve…Facebook application platform is the latest buzz in this space, and is attracting huge crowd within very few days.

By the way, Marc Andersson is a fantastic read for people like me (startup aspirants)…a series of articles on life-of-startups here. There are 6 excellent articles in this series so far.

P.S. Reliance is also getting into this space with BigAdda…so the action is getting hotter day by day… 🙂

Internet Advertising Economics

June 13, 2007

With web 2.0 startups popping up everywhere like mushrooms these days…it is getting difficult to distinguish real diamonds from the fake ones. Everyone is offering a great free, consumer friendly, lightweight, AJAXified, ultra modern Web 2.0 service, and expecting to make it big with Advertising revenues.Total indian Advertising industry would be a minuscle 100million$ as compared to app. 16 billion $ market of US. Find an interesting discussion here. Moreover, it’s not only about advertising. Advertising is a mirror of industry depth. For example, a business model like RearDen, a company focusing on business travel, would be useless in a country like India as of now, as we are far from being habitual in using internet for day-to-day needs. Moreover, we can afford to hire a person as a secretary, which Rearden tries to get away with. So, the complexity and depth of industry, especially the industry that heavily relies on internet is nowhere near US.

Even among current internet userbase of 20 million, it would be very interesting to know what is the amount of money being spent per person on internet, on e-shopping, or ticket booking. Of course, the internet awareness will increase very fast. Today’s college goers are very net savy, even in small towns. They are tomorrow’s earners and comsumers. So, picture after 10 years might really be radically different.

Quite a few startups have come up in online ad networks space.

Tyroo sold their stake to Yahoo very recently. They also have an Ad agency, Quesar media, under the same umbrella (Smiler interactive group). So, it might be their key USP.

Komli, is another one, started by Amar Goel, an ex-microsoft. They, I believe, are focusing on optimization of delivery, using behavioral targeting as their key USP. But, statistical methods and optimizations would be helpful when one already has a big portfolio of media and advertisers available. Google can show extremely relevant ads, based on geography and content type, only because it has a huge footprint among advertisers, as they say, ‘the long tail‘ or ‘bottom of the pyramid’. By the way, does anyone know what this name, ‘Komli’ means? 🙂

There is one more, called Ozone media, but not sure what they are upto.

Doug Lenat video on Cyc

May 3, 2007

Watched a Doug Lenat’s Tech Talks Video on Cyc. Every time I come across something in AI, I feel a strong urge to do something in this field…but now I am miles away from something like this… 😦

That Javascript thing…

April 26, 2007

I have always tried to stay away from Javascript…

I used to write some code hesitantly, say to move data between two listboxes, re-calculating some stuff when values change etc. etc. But overall, I avoided it for the simple reason that it appeared a very weired language to me especially as I cam from strongly typed languages like C++ and Java.

Even simple things like DOM manipulation with getElementById() becomes a challenge with JS.

I know very little Javascript, but a few questions I searched for didnt yield many answers on web…

1. Why there is no standardized library for Javascript, as say there is for JSP custom tags (JSTL) or C++ standard template library?

2. Why IDE’s dont have great support for Javascript? Why do I need to download a plugin like JSEclipse for JS editing in Eclipse?

3. Why javascript is not statically typed? Now dynamic typing might have some benefits, but the winner is clear now. Dynamic typing makes extremely difficult to provide auto completion for IDE’s, Dynamic typing can’t find out all bugs while coding etc. etc.

4. What is happening with Javascript 2.0? Are there any revolutionary changes? I dont have the patience to read through the proposal. 😛

Any way, with a strong arrival of AJAX, I’ll have learn javascript now…planning to get started… 🙂

Eclipse + Weblogic + Debugging with hot deployment

April 25, 2007

I had this simple problem…

I have a web application…to be deployed on weblogic…I use Eclipse to work on it…I am in development mode, so I make frequent changes to Java files and JSP’s and want to see the effect of changes immediately on browser.

In obscure world of Java…it was not that easy I found…

It has to be an open deployment (where you dont create an archive, but ask the App server to point to your development directory)…


With normal Eclipse debugging using Weblogic instance…it unnecessarily creates an archive…I didnt find an option to use open deployment here.

So one needs to use Remote debugging…It is something with which the server needs to expose its debug data to the IDE on some port (in this case 1044). IDE attaches itself to it.


One needs to make changes to the startup file of the App server to use -Xdebug option to start the JVM in debug mode and expose debug data on some port.

In my case, I created a new CMD file from existing weblogic startup file with following debug options added to JVM startup command.

set DEBUG_OPTS= -Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y

Finally, it did work after some worries and mistakes…
Now I can put a console print in some java class and just refresh my browser to see the output in the console…(of course you need to set ‘Build Automatically’ in Eclipse)

What a relief… 🙂

Reference: http://www.jacoozi.com/index.php?option=com_content&task=view&id=119&Itemid=134

ब्लॉगर अब हिंदी में !!!

April 19, 2007

अब मैं हिंदी में लिख सकता हूँ। बिना झंझट के। यह ब्लॉगर तो कमाल कि चीज है! बराहा कि कोई जरुरत नही। 🙂

हे लवकरच मराठीत व्हाय्ला पाहिजे (Semantic word detection will not work in Marathi right now…even though the font is same।)

Googleto ergo sum !!!

April 18, 2007

Google is getting all pervasive on web…not a news of course…but I had a strong realization about this when I created a small tool of custom search using Google tools…

1. Google offers a way to create your own custom search engine. (http://www.google.com/coop). You can basically customize what sites should be scanned for the search and some more parameters. I used this feature to create a custom search engine for Indian stock markets. It was frustrating sometimes to see results from all over the world when all you care about is really NSE listed stocks. Google’s indian site also works, but includes a lot of indian sites I don’t care about.

2. Then I used Google pages (http://pages.google.com/) to create a small home page to host this search. Google pages has a HUGE collection of gadgets, right from news tickers to proxy sites. Not all of them work though. Overall I had a feeling that there is a lot of scope of improvement in Google pages interface. E.g. you cannot edit the overall structure of the page, but have restrict yourself to edit only sections as given by the template.

3. Once my page was online (http://stocksearchindia.googlepages.com/) I entered small code snippets from Google AdSense (https://www.google.com/adsense) to have some Ads on my page. Not sure if it will earn any money though. 😉

4. I put another small snippet from Google Analytics (http://www.google.com/analytics) to get all the statistics about my site’s clients with clean graphs et al. The facilities given by Google Analytics are really awesome, moreover all free of cost of course :).

5. And right now, I am conveying all of this in Blogger.com, which is again a Google acquired company of course. As Descartes once said, ‘Cogito ergo sum’ (I think, therefore I am), a netizen from 21st century (at least from first few years of it…) would certainly say…’Googleto ergo sum’…’I google, therefore I am’ !

’मजेत जगावे कसे’

April 18, 2007

मराठि मधिल पहिला blog लिहित आहे.

’मजेत जगावे कसे’ नावाचे एक सुन्दर पुस्तक सध्या वाचतो आहे. आतिशय सोप्या भाषेत, वेगवेगळ्या प्रसिध्ह इन्ग्रजी पुस्तकान्चा सन्दर्भ घेत शिवराज गोर्ले यानी एक उत्तम Self Help पुस्तक वाचकान्च्या भेटीस आनले आहे.

हुश्श !!! …मराठि टाइप करणे एवढे कठिण असेल असे वाट्ले नव्हते…दमलो मी.

Why Not not start a startup

April 18, 2007

Paul Graham of Y-Combinators has written an excellent article http://www.paulgraham.com/notnot.html. He tries to address the concerns that typically one has about starting up…16 of them. Very objectively and logically written. A must read.