Archive for the ‘Google’ category

Get Google Wave invitation

February 26th, 2010

I got 28 Google Wave invitations. I am inviting my friends. I want to bring people in so that they can try it out. If they find it useful. So if you guys didn’t tried it yet. Just leave a comment by filling your correct email address. And I will bring you in.

Google guys take some days to deliver the invitation. So be patience. :)

Wave is in development phase so not available to every one, except invitations. You can also request Google to deliver you. Read more about Google Wave.

Useful cheat sheets on Cloud Computing and Google App Engine for Java

January 12th, 2010

google_app_engine_javaJust read cheat sheets (Refcard) by Dzone on Cloud Computing and Google App Engine for Java. They contain a very jumped to the point and quick reference on these things. You can read to have a quick overview.

Read them here:

Spoken on Google App Engine at a conference in UET

December 19th, 2009

Today I had delivered a workshop on Developing Java Web Applications In Google App Engine. This workshop was the part of events of 3rd International Conference on Open Source Systems and Technologies. It was organized by Al-Khawarizmi Institute of Computer Science , University of Engineering and Technology, Lahore.

I have presented following slides there. Also coded a basic sample application to show how to create and deploy new Java project on GAE. Which can send emails, how to use authentication by Google, and how to do database interaction. It was a very intresting topic for me to present. Participants also liked it.

Comments and feedback is welcomed on the presentation material from you guys.

Domain is not working without www prefix in GAE

October 6th, 2009

The current issue I am working on is to make my naked domain http://mydomain.com to redirect to http://www.mydomain.com in Google App Engine. With www prefix I have configured my domain. But my naked domain is not working. I just found on Google support site that they are no more supporting naked URLs for their app engine.

According to Google support:

I’d like to map my app to http://myurl.com (also known as a naked domain).

Due to recent changes, Google App Engine no longer supports mapping your app to a naked domain. If your domain registrar supports URL redirects, you can redirect from http://yourdomain.com to your app, which can be served from domains like http://www.yourdomain.com or http://appid.yourdomain.com.

For instructions on how to configure a redirect for your Google Apps domain, please see the article on URL forwarding.

Issue can be resolved if Google provides us IP address and we set a A record pointing to that IP address. But they dont. :(

If you guys have idea how naked domain can be configured with this URL Forwarding thing please feel free to share. I will also update if I got this problem resolved.

Helpful resources:

How to avoid DeadlineExceededException in Google App Engine

October 3rd, 2009

If you are developing web application on Google App Engine for Java. And you dont know what this exception is. You can be in trouble. The container throws this exception for those requests which take time more than 30 seconds. In other words GAE wants every requests to be fullfilled within 30 seconds.

Case
I am developing a Twitter application and I got this exception when I login my Twitter user name. I have some 120 friends and 170 followers. So I need to fill two lists of Twitter users with their name and image URL. It was a bad practice from my side that I started populating lists in a loop which contain external service lookup overhead (Twitter) and also big in iteration. So I got following exception.
This request (670f658c2bf64b44) started at 2009/10/02 23:18:23.902 UTC and was still executing at 2009/10/02 23:18:52.605 UTC.

Possible solution
As for those users who have friends and followers in thousands, this problem will persist. So what I am thinking is to put lists in session. Populate the page with first 30 users. And give a link to next 30 (paginate). I will keep updating two variables in session which will tell start and end to pick the users from the list. I will use DWR for this. By this my every request will be responded by container with in 30 seconds.

If you guys have some more optimum solution for it, please share me. Another solution has been discussed here too.

Tutorial: Java based Twitter App on Google App Engine

October 3rd, 2009

google_app_engine_javaTwitter a microblogging service is getting more and more popular these  days. A lot of developers are involved to develop applications on its  API.

Two weeks ago I click with a very basic idea and being as a matter of learning I started working on it. I have finished more than 80% of the work. I deployed the application on Google App Engine (I hope you are familiar with it). I used Twitter4J lib a Java wrapper for Twitter API.

If you are also interested in Twitter based app development in Jave, then this tutorial will be helpful for you. Feel free to add comments at the end of the post, I will love to reply.

Things you require for development

Things you need to know before you start

Oauth authentication

You should know Oauth basics and its terminologies. You can little google on it or read this FAQs

Register an App with Twitter

You need to register an application on this URL: http://twitter.com/oauth. Please take care of two things. The call back URL will not be your localhost URL. It should be a valid web address. And while choosing Default Access Type, if your application need to do changes or send tweets then you should choose Read & Write otherwise/if you just want to do readonly operations then leave Read-only checked.

A little bit about Google App Engine

Google App Engine is cloud based hosting environment. You should read on their web or on a post by me.

Steps for any Twitter App

  1. User is on your website
  2. Generate a token
  3. Have a hyperlink and take user to the Twitter from your website for authentication
  4. User will enter its user name and passeword and press allow
    If user’s credentials authentiecated Twitter will call the callback method which you had mentioned. Note that localhost URLs will not work here. You need mentiona a valid web address which will be invoked when user will be authenticated.

Code Section

I will assume that you have developed a helloworld prject in Google App Engine and deployed it on appspot.com domain. Code snippet is available in 2 servlets and 1 jsp page.

LoginServlet.java

Twitter twitter = new Twitter();
twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
RequestToken requestToken  = twitter.getOAuthRequestToken();

String token = requestToken.getToken();
String tokenSecret = requestToken.getTokenSecret();

HttpSession session = request.getSession();
session.setAttribute("token", token);
session.setAttribute("tokenSecret", tokenSecret);

String authUrl = requestToken.getAuthorizationURL();

request.setAttribute("authUrl", authUrl);
RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
rd.forward(request, response);

Consumer key and secrets will be generated when you register an application with Twitter. You need to keep token information into session so that you can use the token when callback URL will be called. authUrl is a link which will take user to the Twitter website for authentication. And if authentication successful it will call your URL mentioned as callback.

login.jsp

<a href='<%=request.getAttribute("authUrl") %>'>Sign in with Twitter</a>

HomeServlet.java (as callback URL)

Twitter twitter = new Twitter();
HttpSession session = request.getSession();

twitter.setOAuthConsumer(Constants.CONSUMER_KEY,
Constants.CONSUMER_SECRET);
AccessToken accessToken = twitter.getOAuthAccessToken(
(String) session.getAttribute("token"), (String) session
.getAttribute("tokenSecret"));
twitter.setOAuthAccessToken(accessToken);

User user = twitter.verifyCredentials();

HomeServlet is your callback. Let say you have mentioned URL mapping of this servlet as /Home. So you mention http://.appspot.com/Home in callback field in your app registeration page at twitter. And this HomeServlet will be called. Now you have the user object to play with. See Twitter4J javadocs for more help.

WEB-INF/appengine-web.xml

<sessions-enabled>true</sessions-enabled>

You need to add this tag in you appengine-web.xml file that you are enabling the session.

So this was a tutorial, feel free to ping me on it. If you stuck somewhere. We will both look into it.

I also suggest following links to you people to must visit them. They helps me a lot in the understanding and the development. I will update this tutorial if got more things to discuss.

Helpful Links

Google Code Jam is back for year 2009

July 22nd, 2009

code_jam_logoGoogle has announced its annual programming competition for year 2009.

According to Google blog

Registration is now open, so you can find out more about the contest, and practice on some sample problems. Practice hard! If you make it to the top 500, you’ll travel to a nearby Google office for our semifinal round. If you’re in the top 100, we’ll fly you to our Mountain View headquarters to compete with the world’s very best.

Google is taking this competition as a fine grained recruiting process. Because while registering with Code Jam they will ask what Google office location suits you. Well fair enough, they are giving money to winners and an offer to work in Google. I hope this time I will be able to solve problems in qualification round. Last time I able to solve only one problem which works fine by given test cases but Google didn’t accept :( . That fairly means I need more practice.

Announcement of Google Chrome OS: New idea of providing operating system in a browser

July 10th, 2009

google_chrome_logoGoogle has recently introduced the launch of Chrome OS as an extension to Internet browser. Being a unique idea they claimed to provide a full operating system in browser running on your machine. As all of Google products are online they have trained their users to think every service to be available on Internet. Believe me this is really a matter of spreading a trend in people. And the browser is the most frequently used software on an operating system. What I think they will putt all their products in that operating system.

According to Google blog

Google Chrome OS is an open source, lightweight operating system that will initially be targeted at netbooks. Later this year we will open-source its code, and netbooks running Google Chrome OS will be available for consumers in the second half of 2010.

Google Chrome OS vs Microsoft Gazelle

Developing an operating system was the most awaited thing in Intern user base. As all the products Google launched they were full of innovation and based on crazy ideas. I also came to know about the launch of new Internet browser by Microsoft too named ‘Gazelle’. The interesting thing is it also based on the same idea to provide an operating system in a browser. Google just hit before Microsoft make an announcement. Why both of these companies were involved to developing products based on similar idea? Is it idea theft sort of thing? Who did it first? Well all such kind of questions will be answered on the comparison of feature in these two products.

The developers of these companies are imposing their ideas on people to live like they think. Don’t they? :)

iGoogle theme designing competition for students. Earn cash prize of $7500

May 25th, 2009

igoogle-logoGoogle is conducting a worldwide iGoogle theme designing competition. The competition aims to unleash talented student photographers. And their work will be demonstrated to million of Google users.

Winner will get:

  • £5,000 ($7,500) cash prize
  • work will be demonstrated at Saatchi Gallery in London
  • an invitation to spend a day with renowned photographer Martin Parr

Last date of submission: May 31, 2009

Enter by submitting a series of five photographs at google.com/photographyprize. Top thirty six enteries will be shortlisted and made open for online public voting on June 11.

Get your free business cards from Google

May 2nd, 2009

Google has recently introduced a new feature of Google Profiles. So to promote this feature Google is giving away printed business cards. First 10,000 people will get 25 business cards to their doorsteps. Currently this offer is available in US only.

To order your cards, go to http://www.google.com/profiles/me/ and at the top the link is available in red legend.