Wednesday, July 22, 2009

Orkut Ad Block

I just realized that orkut has shamelessly started putting random and embarrassing ads.
So, I tried AdBlock Plus which doesn't seem to work. So I quickly wrote a script to block the ads from orkut.

Here is the JS script for GreaseMonkey:

var timeOutIds = [];
function clearAllIntervals()
{
for(var i=0; i< timeOutIds.length;i++)
{
var id = timeOutIds[i];
window.clearInterval(id);
if(console)
console.log('cleared the interval : ' + id);
}
}
var total = 0;
function hideBlock()
{
if(total > 10)
return;
else total++;
var frame = unsafeWindow.frames['orkutFrame'];
if(frame)
{
var div = frame.document.getElementById('rhs_ads');
if(div)
{
div.setAttribute('style', 'display:none');
clearAllIntervals();
console.log('Hiding the ad');
}
else
{
console.log('ad div not found.');
}
}
else
{
console.log('ad frame not found');
}
}
var timeOutId = window.setInterval(hideBlock, 1000);
timeOutIds.push(timeOutId);
console.log('scheduled : ' + timeOutId);


All you have to do is install the greasemonkey ad-on for firefox. And the an icon of a face would appear on the right bottom of the screen.
Just right on that icon and say new user script.
Under includes put 'http://www.orkut.com/*' and 'http://www.orkut.co.in/*'
And when the empty window of editor opens just copy-paste the above script and refresh you orkut screen.

BINGO!! No Ads.

Saturday, July 11, 2009

My First Marriage Anniversary

It was our first marriage anniversary (9th July) so we went out to Shamirpet Lake while sister was planning some big surprise at home. It was a great at Lake. We roamed around a lot.

On the way back on our skooty, an auto (full of eggs) was overtaking from left. Yes, from left. It is common in Hyderabad. As I applied the brakes, one car (perhaps Qualis) started over taking from right. The right side of handle hit the car and we fell down.

I wasn't hurt but there was a lot of blood around. It was Sravani's thumb. It was crushed badly but she was calm and in senses even after realizing what happened. Leaving my skooty there, we waved for lift. Thanks to Hyderabad culture we got lift quickly. He left us Appollo. After First Aid and X-ray, we were told that there is no need of amputation, just the surgery will do but there is no surgeon available.

By this time, Ritesh (my business partner) with Lokesh (my co-worker) has reached hospital and took us to Yashoda. I knew plastic surgeon here so I called him on mobile. He did the operation and Sravani was admitted for a day.

Today, we got relieved and are back. We celebrated our Anniversary my sister's way.

Nevertheless, It is more memorable day now.

Wednesday, June 03, 2009

Bing-Bang: Microsoft might monopolize the web market

With the advent of Bing, Microsoft might try to eat the market. I am getting the hibbie-gibbies after thinking about it.

I remember my days before Google. People used to open at least 2 windows for search (Most prominent were Alta Vista, Yahoo and ask jeeves) in Netscape Navigator. We had to keep opening lot of windows as the thing we were looking for might even be on the second page of search results. Since the net was slow, we would be more aggressive about opening as many windows as possible. One top of that, since PCs were few more then one person would use a PC to search.

First Microsoft Killed Netscape.

We were left with IE and we all know the history of IE. The one responsible for most of the viruses around.

Anyway, lets get back to the search engine.
Now, one fine day (after living with the internet for around 2 years), I came to know about Google. I still remember the feeling of the first page. It looked like designed for non-profit by some student because we were used to seeing the popup/ad-filled pages. Since that day, I haven't looked back to any other search engine for serious use. Google was definitely 100 times (i.e. 10,000 %) better than yahoos and altavistas.

Now, Bing comes with hardly -1% to +1% improvement( effectively 0%) and $ 100 M ad budget. I feel that given that budget microsoft can takeover the market. Reason being simple "99% People breathe windows. Windows is their conscience".

What if IE6, IE7 and all the stuff that links to search engine, all points to Bing? And the user find the things which he is looking for on Bing. will anyone care to open google?

No matter how bad MSN Messenger had been, it always had biggest user base. Reason was simple, microsoft forced every one to open an account from inside windows. There are links everywhere (when you run outlook express, netmeeting etc etc.).

MSN live space still claims to have 3rd biggest user base (after myspace and facebook). Did you ever heard about MSN live space? I opened once but never used afterwords.
So, the key point is Microsoft's marketing and control over me could trick me into opening an account but could not hold me longer.

Since for search engine, user has less inertia of change as compared to emails or a social network. There are chances that people who are taken to Bing at least 4-5 times would remain there.

One of the main crowd pullers for Google is Firefox to whom they pay $50m to $66m a year. Can't Microsoft snatch that deal now?

Given all this thought process, I feel that Microsoft will have 50% share in search engine market in 1 year.

So, my question remains to Google, "why didn't you create an OS for a normal user? Why?!"
See, all of the end users of windows suffer. At lest 20% people who are using windows have one problem or the other. An individual has to format his/her windows pc at least once in 3 months. This is based on my 8 years of experience.

I feel there is a huge scope of improvements. I am using Mac for past 1 year and it has been such a breeze. I never looked back.

I have used Linux but it doesn't provide a great UI experience. One has to be at least 10 times better than windows to beat it at this time.

So, My conclusion is this, Unless Google comes up with a search engine which is 10 times better then current Bing or an OS which is 10 times better than windows, it would be difficult to survive.

Disclaimer: This is my personal view point based on the current situation. I can not be held by neck for any of this.

Monday, January 26, 2009

Setting the gmail's status as 'a new fortune quote' automatically

This tiny little thing sets my status after picking it from the unix command called 'fortune' (it gives out a quote possibly funny).
So, I just used Smack API and implemented it.


import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence;

public class PresenceGoogle extends IQ {

protected String userName;
protected String status;
protected boolean visible;
protected Presence.Mode mode;




/**
* Override toXML in the case of mode is away
* Because Google Talk interprets the 'away'
* status as idle, and idleness is a
* per-connection property, you cannot set an
* 'away' status using this method. To set an
* idle status message, send a
* standard stanza. :
*/
@Override
public String toXML() {
if ( mode.equals(Presence.Mode.away) )
{
Presence p = new Presence(Presence.Type.available);
p.setMode(mode);
p.setStatus(status);
return p.toXML();
}
else
{
return super.toXML();
}
}


/**
* Constructor
* @param userName the userName
* @param status the new status
* @param visible the visible state > false to be invisble
*/
public PresenceGoogle(String userName, String status, boolean visible) {
super();
this.userName = userName;
this.status = status;
this.visible = visible;
setType(IQ.Type.SET);

// I am not sure this code must be test
// in case of a domain different of gmail.com
// using gmail.com...
if( userName.indexOf("@") != -1)
{
setTo(userName + "");
}
else
{
setTo(userName + "@gmail.com");
}

mode = Presence.Mode.available;
}

/**
* Constructor
* @param userName the userName
* @param status the new status
*/
public PresenceGoogle(String userName, String status) {
this(userName,status,false);
}

/**
* Return the XML of changing status
* for google
* according
* http://code.google.com/apis/talk/jep_extensions/shared_status.html
*/
@Override
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();

// set query header
buf.append("");
// set status
buf.append("").append(status).append("");
// set mode
buf.append("").append(mode).append("");
// set invisible mode
if ( visible )
{
buf.append("");
}
else
{
buf.append("");
}
// close query
buf.append("
");

return buf.toString();
}


public Presence.Mode getMode() {
return mode;
}


public void setMode(Presence.Mode mode) {
this.mode = mode;
}

}

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class SetStatusMessage {
public static XMPPConnection getConn() throws XMPPException
{
String login = "sandeepxxxxgiri@gmail.com";
String pass = "xxxx";

return getConnection(login, pass);
}
private static XMPPConnection getConnection(String login, String pass)
throws XMPPException {
XMPPConnection connection = new XMPPConnection("gmail.com");
connection.connect();
connection.login(login, pass);
return connection;
}
public static void setStatus(XMPPConnection connection, String msg)
{
PresenceGoogle pg = new PresenceGoogle("sandeepgiri",
msg, true);
connection.sendPacket(pg);
}
public static void setStatus(String login, String pass, String msg) throws XMPPException
{
setStatus(getConnection(login, pass), msg);
}

private static String readStdIn() throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

StringBuilder input = new StringBuilder();
String str;
while( (str = br.readLine()) != null)
{
input.append(str);
}
return input.toString();
}
public static void main(String[] args) throws FileNotFoundException, IOException, XMPPException {
String login;
String pass;

if(args.length == 2)
{
login = args[0];
pass = args[1];
}
else if(args.length == 0)
{
String userHome = System.getProperty("user.home");
if (userHome == null) {
throw new IllegalStateException("user.home==null");
}
Properties props = new Properties();
props.load(new FileInputStream(userHome + "/.setstatus.properties"));
login = props.getProperty("login");
pass = props.getProperty("password");
}
else
{
System.out.println("Usage: \n 1. setStatusMessage \n\t Sets the status message using the login and password.\n 2. setStatusMessage \n\t Reads login and password from .setstatus.properties");
return;
}
String quote = readStdIn();
setStatus(login, pass, quote);
}
}

Then I wrote this command setfortunestatus.sh:
$cat cat ~/scripts/setfortunestatus.sh
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smack.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smackx.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smackx-jingle.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus
/opt/local/bin/fortune -s|java -classpath $CLASSPATH SetStatusMessage

Now, I scheduled it using Lingon in my macos x.
In case you do not have fortune on your Mac OS X, you could just use "sudo port install fortune". This would use fortune macport.

Saturday, January 03, 2009

Alive Again with GWT

Since I have switched to Web Programming I had almost lost my charm to do programming because most of the time would go into data plumbing:
1. Getting the data from database and creating objects
2. Taking these objects filling into the templates
3. Generating HTML from servlets
4. Converting my Java objects in XML or JSON etceteras etcetras...
5. fixing browser incompatibilities
6. SQL Queries incompatibilities amongst various Databases.
7. Worry about typos in JS code which will take hell lot of time to figure out.

So, recently I discovered GWT (Google Web toolkit). Its not that I didnt know about GWT, I have known it for more than a year.
But recently I found that it makes the service call as easy as calling a method of library - Passing the argument and getting the objects returned. Wonderful! It solved problem 2,3,4, 5 & 7.

Regarding remaining problems, I think Hibernate would do. Let me give it a try. It seems to have a big learning curve.

I then rolled up my sleeves and wrote my first Web Application which was done out of self interest. Yes, I mean it the first webapp for fun. So far, I had been designing applications out of business need. Perhaps I have written around 7-8 web applications so far. I have been doing it since 2001.

I wrote my first app called 'Talk' - it is similar IM but you dont have to press enter..It is sent as you type. If you have used talk of unix, you woould understand.

Looks wonderful. I am about to finish it and then I would host it on google code. Then you have understand what it looks like. But definitely it would be more interesting then exising IMs.

Saturday, December 06, 2008

Monitoring your servers with shell script

Here is my take on monitoring system.

Purpose:
The idea is to monitor the servers and see if X server is running on Y port. I generally have to monitor 4-5 servers and have to check whether MSSQL, Mail Server, Tomcat etc are running on these machines.

So, I maintain a server.txt which has:
server1 80
server1 1433
server1 25
server2 80
server3 25

$ cat monitorserver.sh
#
# This script reads server.txt and checks if each of the server is up using tel.sh
#
SCRPT_HOME=`dirname $0`
cat $SCRPT_HOME/server.txt |while read server port;
do
ret=`$SCRPT_HOME/tel.sh $server $port`
if [ $ret = "0" ]
then
msg="$server at $port is down"
say $msg
fi

$ cat tel.sh
#It takes two args one server other port and print 1 if up otherwise 0
((echo "o $1 $2"; echo "quit")|telnet 2>&1)> /dev/null

Sunday, November 23, 2008

How much time would it take to copy?

You are copying files A, B, C, D from place SOURCE to TARGET.
The progress of each as displayed by windows is:
A: 10 minutes remaining
B: 30 minutes remaining
C: 75 minutes remaining
D: 157 minutes remaining

How much time would it take for the copying to finish?

Assumptions:
1. The bandwidth is evenly distributed amongst various connections.

The macbook hardware sucks

Can you believe that two harddisks crashed in a year?

I got a macbook on sept 7, 2007 and the hard disk was crashed in feb 2008. Can you believe it?
And worst part of it, Apple knows about it? If they knew about it why didnt they notify users and got it back?
I am keeping my whole business data in it. It is not only about the goddamn Rs. 2000/- worth!
Fine. They replaced it then since it was in warranty.

And now again it crashed on 21 Nov 08. Now the laptop is no longer in warranty.
This is not the first laptop I am having. My Acer one which I bought in 2003 still works cool. I have worked on that alot.
So, The question remains how can a hard disk crash in just 8 months?
Possibly they put some hard disk which was destined to fail as soon as I am out of warranty.

The apple resellers suggested me to buy further warranty for 2 years which was costing me 13K. And this is how those guys tried to convinced me to buy a warranty:
"See sir, the combo drive which is known to fail after a years costs 14K. I would suggest you to buy warranty cover."

I mean "What?" It like selling you the insurance by showing you a gunmen and then telling "See any one can be shot any day. This our gunman has shot around 10 people last year."

I think I would buy the warranty because I see no choice but in future I am not going to buy this god damn thing.
I like the quality of Mac software so I would rather buy some other may be IBM's laptop and install mac os x on that.

Guys, in case you are planning to buy a mac. Buy any other high end laptop and install Mac OS X under Virtual Machine. VM have become quite stable and efficient these days.

Hope it helps.