Sunday, October 21, 2012

Vim editor - Paste toggle

You may have experienced an additional spaces or unexpected indentation when you paste some text into Vim from another application. To avoid that you need to set paste toggle option in Vim

Follow the steps below

$ vim ~/.vimrc

Put the following in your vimrc (change to whatever key you want):
set pastetoggle=

save and exit.

To paste from another application:
   * Start insert mode.
   * Press F2 (toggles the 'paste' option on)
   * Use your terminal to paste text from the clipboard.
   * Press F2 (toggles the 'paste' option off).


Friday, June 15, 2012

HowTo.. ?

A collection of some important "HowTo"s that I have come across..

Hope to periodically update the list as I get to know of a new "HowTo" ..



Mount a remote samba server shared directory in Linux (Ubuntu)

      $  mount -t cifs //10.2.5.5/shared -o username=un,password=pw /test


Extract a "tar.gz" file in Linux
    
     $ tar -xzf tar-file-name.tar.gz
  • tar - the tar command.
  • x - extract the archive.
  • z - uncompress the archive using gzip.
  • f - use archive file.
  • tar-file-name.tar.gz - the name of the tar.gz to create.
The tar command will extract all the files/folders in the archive to the current directory. 

Create a "tar.gz" file in Linux
    
     $ tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2
  • tar - the tar command.
  • c - create new archive.
  • z - compress the archive using gzip.
  • f - use archive file.
  • new-tar-file-name.tar.gz - the name of the tar.gz to create.
  • file-or-folder-to-archive - the name of the folder we want to archive.

Mounting and un-mounting Qemu image


nbddevice="/dev/nbd2"
nbdmount="/dev/nbd2p1"


modprobe nbd max_part=8
qemu-nbd -c /dev/nbd2 image_path
mount /dev/nbd2p1 $work_dir/$image_template


umount $work_dir/$image_template
qemu-nbd -d /dev/nbd2



wget java
-------------
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com"  http://download.oracle.com/otn-pub/java/jdk/6u39-b04/jdk-6u39-linux-x64.bin

Wednesday, May 23, 2012

JavaScript Services in Action in WSO2 Mashup Server



WSO2 Mashup Server can be used to create and host JavaScript based mashups, acting as a hub for integrating your enterprise with rich information available on the web. Each mashup hosted in here is exposed as a new web service, and can be consumed by other mashups or web service clients.



In this post I'm going to show you how to get started with a JavaScript service, and consume that service inside another JavaScript (A client) embedded in an HTML page.

The scenario I'm going to cover is, developing a JavaScript based service for getting stock updates, which retrieve the stock information by invoking another external web service , and writing a JavaScript client inside an HTML, which invokes the JavaScript service. 


Writing the service

1. Download WSO2 Mashup Server binaries and extract into a convenient location (Hereafter referred to as MS_HOME ) 

2.  The JavaScript service should be written as a standard JavaScript file, as  mentioned below


3. This JavaScript file (stockQuote.js) needs to be placed in the following location
    <MS_HOME>/repository/deployment/server/jsservices/admin

4. Start the server ($ sh /bin/wso2server.sh )

5. If the StockQuote service is deployed successfully it should be logged as "Deploying Web service: stockQuote.js" and verify through Management Console (https://localhost:9443/carbon/service-mgt/index.jsp?region=region1&item=services_list_menu, or http://localhost:9763/services/admin/stockQuote?wsdl)

6. After successfully starting up the server, note that a folder is created in     <MS_HOME>/repository/deployment/server/jsservices/admin with the name stockQuote.resources.
Create a new folder with the name "www" if such a folder is not there already. Service client related code should be place in that folder.


Writing Client code and Installing a custom UI

JavaScript clients can invoke services via generated stubs. The generated stub is again a JavaScript file. It can viewed as follows,
http://localhost:9763/services/admin/stockQuote?stub

1. The sample code of StockQuote service client is listed below, note that it is embedded in an HTML file (which is the UI of your service) and in the top you can see a reference to the generated stub is included. Save this as index.html file into the "www" folder created above.
<MS_HOME>/repository/deployment/server/jsservices/admin/stockQuote.resources/www



2. Access the UI of the as follows to test the functionality
        http://localhost:9763/services/admin/stockQuote/
     In the text box, input a Stock symbol (eg: GOOG, IBM, VRTU .. etc) and check the results



Troubleshooting

In some situations, the generated JavaScript stubs are having some issues (which are already identified and will be fixed in the next release)

In such a scenario, as a hack you can do the following.

1. Access the stub (http://localhost:9763/services/admin/stockQuote?stub) and save the stub file in <MS_HOME>/repository/deployment/server/jsservices/admin/stockQuote.resources/www location as "stockQuoteStub.js"

2. The "bf2xml" function of the stub is the culprit here, so as a fix replace the relevant code related to bf2xml function with the code below


3. In index.html file modify the line which has the reference to the stub, so remove the line
  

and add the following line instead
 


Note that, now it is referenced the modified version of the stub, which is in the www directory

4. Now the issue should be fixed.

Friday, August 26, 2011

A Spontaneous Ad-hoc network to Share WWW Access (Raquel Lacuesta et al.)

This is a summary of the research paper A Spontaneous Ad-hoc network to Share WWW Access, done by Raquel Lacuesta et al. I chose this paper to present in my MSc course module, Mobile Computing.

In this paper, authors have proposed a secure spontaneous ad-hoc network, based on direct p2p interaction, in order to achieve a easy, quick and secure WWW access to the users. According to them, they are the first group of researches to come up with a design and a simulation of spontaneous ad-hoc networks.

Their paper is structured as follows
  1. An introduction to spontaneous ad-hoc networks and relevant literature
  2. The model they have proposed.
  3. Auto configuration procedures used in their model.
  4. A mathematical analysis.
  5. Security related things.
  6. The protocol procedure and messages
  7. Comparison of the proposal with some caching techniques
  8. Validation of the model through simulation
  9. Summary of the work and conclusion

Introduction

A mobile ad-hoc network can be briefly defined as a group of wireless nodes collaboratively form a network, which operates without the support of a fixed infrastructure. Several applications of such networks are; data collection in sensor arrays, communication in hostile or disaster stricken environments. Main challenges present in ad-hoc networking are that those should operate independent of an access point infrastructure, where nodes are unreliable and unpredictable. Also, the network should be able to provide administrative services need to support applications despite the fact that it operate independent of a pre-configured or centralized network management infrastructure. This is different from an infrastuctured networks, where those services like address allocation, name assignment are handled by a central authority of global scale. Name resolutions, file system management, mail and web services are centrally administered. Many general applications are server-based and hence preconfigured by human administrators and network tools. But in ad-hoc networks those services cannot be centralized and preconfigured because the network population and topology is not known in advance and also unpredictability of the network causes configuration needed to be changed rapidly.

A spontaneous ad hoc network is a type of ad-hoc network which is formed in a certain time during a period of time, with no dependence on a central server and without the intervention of expert users in order to carry out a specific task. The network is built by several independent nodes and the nodes are free to enter the network as well as leave the network whenever required. An example for a spontaneous network is when a group of people get together and use wireless computing devices for some computer based collaborative task. In spontaneous networks, users do not need to identify all the participating human and devices or don't need to configure their devices in advance.

Main features of ad-hoc networks can be described as follows.
  1. Network boundaries are poorly defined
  2. The network is not planned
  3. Hosts are not preconfigured
  4. No any central servers
  5. Users are not experts
Another important thing about spontaneous networks are that the participating nodes are limited in resources and power. Caching techniques have used in this model in order to avoid the nodes being overloaded.


Spontaneous Network Proposal Description

When a device joins a network following steps must be followed
  • Device should be integrated into the network
  • Service and Resource discovery
  • Accessing the services discovered
  • Collaborative tasks
A quick creation and configuration is very important for the performance of spontaneous networks, in the model described here authors have followed a way which requires minimum human intervention when setting up the network.


Saturday, March 5, 2011

My Research Areas

Workflow Engines - BPEL / Apache ODE / Web services orchestration


Friday, September 24, 2010

Quick fix for Eclipse Galileo GDK issue in Ubuntu Karmic Koala

Due to an incompatibility issue with GDK windows kit in Eclipse Galileo version in Ubuntu Karmic Kola environment, some buttons of Eclipse IDE are disabled, which blocks users from creating a simple Java project in Eclipse.

There is a quick fix for this issue.

Write a wrapper script (eclipse.sh) including following lines
export GDK_NATIVE_WINDOWS=1 # This line contains the fix.
/home/sajith/Dev/IDE/eclipse/eclipse # This line is for executing eclipse.

Setting Your Development Environment in Ubuntu (10.04)

Setting JAVA_HOME variable

If .bash_profile file is not in the ~ directory, use .bashrc file instead.

export JAVA_HOME variables and add those to PATH as follows.

export JAVA_HOME=/home/sajith/Software/jdk1.6.0_19
export PATH=$PATH:$JAVA_HOME/bin



Creating a symbolic link for Java

When you are trying to start up eclipse and then If you getting an error like this

"A Java Runtime Environment (JRE) or Jave Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations"

you have to create a symbolic link to java should be created in /usr/bin

For that excecute the following command
$ ln -s /home/sajith/Software/jdk1.6.0_19/bin/java /usr/bin/java