Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Monday, February 11, 2008

Google AJAX Search API

Hi,

While browsing through, I just stumblled upon what is known as Google AJAX Search API.

I was in seach of something where I could encorporate a google search right into my blog and which looks a touch different than the normal search page from google.

And I did well to land upon the Google AJAX Search API

It was quite simple and had enough tutorials and sample codes written for someone looking to encorporate a decent search into their site.

Take a look at the search box at the right bar on the blog. And try searching for something through it. It displays the results for each category as a seperate tab on the very same page.

Here is the way to encorporate the same in your blog.

1. Obtain a Google API Key. This is a kinda composite key for all the services of google that we would be using.

2. Integrate the API key code into your blog. OPen your blog and go to Edit HTML and in the head section of your blog, add the following script tag:
<script src='http://www.google.com/jsapi?key=developer_key'
type='text/javascript'/>

3. This will allow us to use all the services that google offers. Now we need to put up the code for displaying the search box. Here is the code for that.

<script type="'text/javascript'">
google.load("search", "1");

// Call this function when the page has been loaded

function initialize()
{

var searchControl = new google.search.SearchControl();

searchControl.addSearcher(new GwebSearch());

searchControl.addSearcher(new GvideoSearch());

searchControl.addSearcher(new GblogSearch());

searchControl.addSearcher(new GnewsSearch());

searchControl.addSearcher(new GimageSearch());

searchControl.addSearcher(new GbookSearch());

// create a drawOptions object

var drawOptions = new GdrawOptions();
// tell the searcher to draw itself in tabbed mode

drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
drawOptions.setSearchFormRoot(document.getElementById("searchPlaceHolder"));
searchControl.draw(document.getElementById("searchcontrol"), drawOptions);

}

google.setOnLoadCallback(initialize);
</script>




4. An explaination of this code is as below:
a. google.load("search", "1"); - This line of code prepares the search API from google and loads all the functions necessary to perfrom the search.

b. google.search.SearchControl();- This is the main control that displays the search results.

c. searchControl.addSearcher(new GwebSearch());- This is used to add various searchers to the control. Add as many searches as you like.

d. GdrawOptions();- A draawoptions object gives you the flexibility of customizing your search results display. The below two lines show the examples of its usage.

e. drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED); - This tells the search control how to display the search results. Here we have set it to display in the form of different tabs.

f. drawOptions.setSearchFormRoot(document.getElementById("searchPlaceHolder"));- This tells the search option the control to which the search box would be bind. I created a div with the ID searchPlaceHolder to hold my search box.

g. searchControl.draw(document.getElementById("searchcontrol"), drawOptions); - This is used to actually draw the search control with the appropriate draw options.

h.
Loading
- This provides us with an instance of a searchcontrol. Place it where you want the results to be displayed.


This way it would display a search box where you place the searchPlaceHolder control and would display the search results where you place the searchcontrol.


Hope this helps a lot of people like me ....

-- Ashutosh

Tuesday, January 8, 2008

Harbhajan Banned for 3 test matches.......

Yes this indeed is a technical blog but being a sentimental Indian, I could not stop myself from writing my own views of the story.

First of all, comments from a few commendable people:

  • "I am South African, and I understand the word racism. - Mike Proctor"
  • "They're entitled to do whatever they think is appropriate at the time but for me that would be a little bit extreme, I must admit. - Ricky Ponting"
  • "What to do? Calls for sackings are knee-jerk, the threat to abandon the tour nonsensical. Apart from anything else, the all-powerful television moguls here and in India would not countenance it. The tour will go on, and so will the captains. So law and order it must be. - Greg Baum (The AGE)"
  • "I saw the footage of what had happened involving Andrew Symonds when the
    Australians were in India. Most of the spectators were just having some light-hearted banter, and there was no malice in most cases. - Steve Waugh"
  • "Michael Clarke also had a dreadful match but he is a young man and has time to rethink his outlook. That his mind was in disarray could be told from his batting. In the first innings he offered no shot to a straight ball and in the second he remained at the crease after giving an easy catch to slip. On this evidence Clarke cannot be promoted to the vice-captaincy of his country. - Peter Roebuck"
  • There are times when you don't know. So, you ask the question. Every player has right to ask the umpire. I will say I don't appeal if I don't think they are out. If I am not sure, I will ask the umpire and I'll accept his decision. - Adam Gilchrist"

SO these are the view of certain people who are known to be experts of their own fields.
Well Mr. Mike Proctor just to let you know, We are the citizens of India and We really do not know what RACISM is. We never hear such words in our country because we never had views and culture as in SA our even Australia where people are discriminated on the basis of color.


And the statement from a reputed person from Australia "WHY SYMONDS ONLY !!" confirms the stand that they still have racism running through their blood. I mean had the same statement been made against Ponting or any white cricketer that would have not been a Racial comment but since it has been againsta Black, it is definitely the ONE..........

Regarding cancellation of the tour - As an Indian, yes I would most definitely like it to happen, but as an ardent cricket fan, I would most definitely like the tour to go on. Because the fight from here on would definitely be an interesting one becuase now it would most certainly not be a mere game of cricket but it would be a question of the national pride at stake.

As Greg Baum quoted - The television media that is presenting the live coverage all over the world is strong enough to make the tour continue. There would be a huge loss to the industry if it does not. After all we are talking of around 3 months of cricket going out of question.

And lastly, to comment on what Adam Gilchrist had to say on Rahul Dravid's dismissal, well Gilli your statement suggests that you were not confirm if that was out or not so you had put up a question to bucknor asking for his openion.

Well I would leave that to the readers to decide upon after having a look at the footage of the dismissal.


--Ashutosh

Wednesday, February 14, 2007

Year 2038 problem

The Year 2038 problem The Year 2000 problem is understood by most people these days because of the large amount of media attention it received. Most programs written in the C programming language are relatively immune to the Y2K problem, but suffer instead from the Year 2038 problem.
This problem arises because most C programs use a library of routines called the standard time library (time.h). This library establishes a standard 4-byte format for the storage of time values, and also provides a number of functions for converting, displaying and calculating time values.
The standard 4-byte format assumes that the beginning of time is January 1, 1970, at 12:00:00 a.m. This value is 0. Any time/date value is expressed as the number of seconds following that zero value. So the value 919642718 is 919,642,718 seconds past 12:00:00 a.m. on January 1, 1970, which is Sunday, February 21, 1999, at 16:18:38 Pacific time (U.S.). This is a convenient format because if you subtract any two values, what you get is a number of seconds that is the time difference between them. Then you can use other functions in the library to determine how many minutes/hours/days/months/years have passed between the two times. If you have read the Tech Touch on Bits and Bytes, you know that a signed 4-byte integer has a maximum value of 2,147,483,647, and this is where the Year 2038 problem comes from. The maximum value of time before it rolls over to a negative (and invalid) value is 2,147,483,647, which translates into January 19, 2038. On this date, any C programs that use the standard time library will start to have problems with date calculations. This problem is somewhat easier to fix than the Y2K problem on mainframes, fortunately. Well-written programs can simply be recompiled with a new version of the library that uses, for example, 8-byte values for the storage format. This is possible because the library encapsulates the whole time activity with its own time types and functions (unlike most mainframe programs, which did not standardize their date formats or calculations).
So the Year 2038 problem should not be nearly as hard to fix as the Y2K problem was. An alert reader was kind enough to point out that IBM PC hardware suffers from the Year 2116 problem. For a PC , the beginning of time starts at January 1, 1980, and increments by seconds in an unsigned 32-bit integer in a manner similar to UNIX time. By 2116, the integer overflows. Windows NT uses a 64-bit integer to track time. However, it uses 100 nanoseconds as its increment and the beginning of time is January 1, 1601, so NT suffers from the Year 2184 problem.


-- Ashutosh