Monday, September 26, 2011

Accelerator Development for Internet Explorer 8+


Introduction
Internet Explorer accelerators are the contextual services available in browser. Arrow Icon appears when you selection some text or image on anything. Click on this icon to get list of all the available accelerators in your browser.  Select or hover any available accelerator to avail the facilities provided by that accelerator.
To manage accelerators click ’Tools’ menu and select ‘Manage Add-Ons’ and then in accelerators tab. You can delete, disable or set as a default according to the usability of that accelerator.
Development
Building an accelerator is just defining a simple XML based on the Open Service specifications. Pages defined for the service can be any language which is able to make HTTP (GET, POST) calls to fetch the desired data over network. Data can be fetched from anywhere; whether it is a remote database or any online service i.e. Google, Yahoo etc.


<?xml version="1.0" encoding="UTF-8"?>
<openServiceDescription xmlns="http://www.microsoft.com/schemas/openservicedescription/1.0">
  <homepageUrl>http://accelerators.myDomain.com</homepageUrl>
  <display>
    <name>My Doamin Title</name>
    <icon>http://accelerators.myDomain.com/favicon.ico</icon>
  </display>
  <activity category="search">
    <activityAction context="selection">
     
<preview action="http:// accelerators.myDomain.com/preview.jsp">
        <parameter name="selection" value="{selection}"/>
        <parameter name="clean" value="true"/>
        <parameter name="w" value="320"/>
        <parameter name="h" value="240"/>
</preview>

      <execute action="http:// accelerators.myDomain.com/index.jsp">
        <parameter name="selection" value="{selection}" type="text"/>
      </execute>
    </activityAction>
  </activity>
</openServiceDescription>


Deployment
Put this xml file in your path of your application domain. Define the pages like index.jsp and preview.jsp which calls network services/ databases to provide the information to users.
In the home page of your domain add some means to add your accelerators. Simply add a button to call window.external.AddService on click of the button, or a hyperlink to call this method.

onclick="window.external.AddService(‘http://accelerators.myDomain.com/accelerator.xml’)"


Installation
On click on the button you shall get following popup asking for permission to install the new accelerator in your browser.

Click on the Add button to install this accelerator in your browser.  To manage accelerators click ’Tools’ menu and select ‘Manage Add-Ons’ and then in accelerators tab. You can delete, disable or set as a default according to the usability of that accelerator

Thursday, September 22, 2011

GooglePlus: ActivityFeed, PlusOnes, Replies, Reshares

Lets have a look how to get all the activity feeds of a user and how to get total number of plusone, replies and reshares.( Google has launched a limited API we can get only the count of plusone, replies and reshares).

I've used java api.

String userId=Constant.USERID;
Plus plus = new Plus(new NetHttpTransport(), new GsonFactory());
plus.setKey(Constant.API_KEY);
ActivityFeed feed = plus.activities().list(userId, "public").execute();


 while (feed.getItems() != null) {
           for (Activity activity : feed.getItems()) {
                     System.out.print(activity.getPlusObject().getContent());
                 
                     ActivityObject obj = activity.getPlusObject();
                 
                      ActivityObjectPlusoners plusoners = obj.getPlusoners();
                     System.out.print("Plus One : "+plusoners.getTotalItems());
                 
                      ActivityObjectReplies replies = obj.getReplies();
                      System.out.print("Replies : "+replies.getTotalItems());
   
                     ActivityObjectResharers reshares = obj.getResharers();
                    System.out.println("Reshares : "+reshares.getTotalItems());
         }
Plus.Activities.List list = plus.activities().list(userId, "public");                list.setPageToken(feed.getNextPageToken()); feed = list.execute();
}

Similarly ActivityObjectAttachment objects can be accessed.
Its pretty easy but very limited as well. :(


Sunday, September 18, 2011

Stream Google Plus

New application for adding a google plus stream in your webstie.

http://streamgplus.appspot.com/



Example app for my blog..


Change the User Id and use the below code to the "Stream G Plus" app for your application...

Let me have your views.  

First Google Plus Project in java

Few days back google has launched its google plus api. I Thought to have some hands on over that.
It pretty simple to create first google plus application. But its a very limited api. Hope more features will be released/added soon.

Now lets get into first google plus applicaion for java
I am gonna do this without any authentication of the user. (Yes thats possible is google plus, for public data only.)

            Plus plus = new Plus(new NetHttpTransport(), new GsonFactory());
            plus.setKey(YOUR_API_KEY);
 
            Person profile = plus.people().get(USER_ID).execute();
   System.out.println(profile.getDisplayName());
 
            List list = plus.activities().list(USER_ID, "public");
   list.setMaxResults(Long.parseLong("50"));
 
            ActivityFeed feed = list.execute();
 
                while (feed.getItems() != null) {
    for (Activity activity : feed.getItems()) {
    System.out.println(activity.getPlusObject().getContent());
    }    
   }

This is simple application to get the Displya name of the user and the list of public feeds from his/her stream.
1. commons-codec-1.3.jar
2. commons-logging-1.1.1.jar
3. google-api-client-1.5.0-beta.jar
4. google-http-client-1.5.0-beta.jar
5. google-oauth-client-1.5.0-beta.jar
6. gson-1.6.jar
7. guava-r09.jar
8. httpclient-4.0.3.jar
9. httpcore-4.0.1.jar
10. jackson-core-asl-1.6.7.jar
11. jsr305-1.3.9.jar
12. junit-4.8.2.jar
13. libplus.jar
14. protobuf-java-2.2.0.jar
15. xpp3-1.1.4c.jar

Soon I'll be posting how to get authenticated will google plus api.

Sunday, September 11, 2011

Create a new GO package

In this tutorial we will learn how to create a new GO package similar to "fmt" and others. There are several advantages of packages. Firstly, if your go application ranges over several files and functionality, its better to have those in different packages. Secondly, if want to publish your own set of go APIs you can simply package them and make available to public.

Lets create a simple GO package with only one function in it.
1. Write a go program.

package file


func TestFunc(name string) string{
        if(name == ""){
           return "Not a valid name"     
        }
        return "TestFunc"+name
}

2. Create a directory naming the package name in "src" folder of GO installation directory.
    Ex: Save this file in C:/go/src/file folder as file.go; as package name mentioned in above program.

3. TestFunc function must start with capital letters since its a convention in GO language that if the function name starts with capital letter then only it will be visible outside the package.

4.Now your package is ready. You just need to install the package. Following are the set of commands you need to follow to install it.

Go to c:/go/src/file and execute following commands.

set gopath=c:\go            (base directory where you put your package)


set gopath                         (confirm the gopath is set or not)

exit from command prompt.

open command prompt again.

Go to c:/go/src/file and execute following command to install the package.


goinstall -make=false .

Now your package is installed and ready for use.

Let's write a program to test it.



package main


import(
        "file"
        "fmt"
)


func main(){
       fmt.Printf(file.TestFunc("Anuj Verma"))
}


Save this file as test.go in any directory. You have your "file" package available with you.
Execute following commands to run it.



8g test.go              To compile it. 


8l test.8               To link it.


8.out.exe               To run it.



This is how we can create our own packages in GO.


Let's GO