Featured

REST

What is REST stands for? Representational State Transfer
OK first lets consider what is REST, REST is a architecture which based on web standards and uses HTTP protocol for data communication. REST architecture treats every content as a resource. we can get text files, html pages, images, dynamic data etc. as resources. Each resource is identified by URIs. (Uniform Resource Identifier) REST uses like text, JSON and XML to represent a resource.  Now you will think what is this URI, resource 🙂
we will discuss more about those later.

OK now lets talk about RESTFul web service. Before talk about RESTFul web service we have to know what is a web service?  Simply we can say, web service is a collection of protocols and standards used for exchanging data between applications or systems. why we want web service, lets think we have two software applications which written in various languages and running on various platforms. So how can we exchange data between those applications? OK now web services come to picture 😀

Now it is very easy to say what is RESTFul web service. If we use REST architecture for a web service we can call it RESTFul web service. Please keep in mind REST is not a programming language or something it is a ARCHITECTURE 🙂

Above we said REST uses HTTP protocol for data communication. RESTFul web services communicate using HTTP request and HTTP response. A client sends a message in form of a HTTP request and server responds in form of HTTP response. we call this technique as Messaging.
HTTP request has five major parts.

Verb –                     This indicate HTTP methods such as GET, POST, DELETE, PUT etc.
URI –                       we can identify the resource on server using this.
HTTP Version –     This indicate HTTP version. eg:- HTTP v1.1
Request Header – This contains metadata for the HTTP request message as key-value                                          pairs. eg:- client type, format supported by client, format of message                                        body etc.
Request body –      Message content or Resource representation.

HTTP response has four major parts.

Status/Response code – Indicate Server status for the requested resource. eg:- 404 Not                                                   found
HTTP version
Response Header –       eg:-content length, content type, response date, server type etc.
Response body –           Response message content or Resource representation.

OOOOOK I think now we know something about REST 🙂 Can you remember, above we mentioned about URI ?
Now you know URI stands for Uniform Resource Identifier. URI identifies each resource in REST architecture. Purpose of an URI is to locate a resource(s) on the server hosting the web service.
This is the format of URI

<protocol>://<service-name>/<ResourceType>/<ResourceID>
eg:- http://www.example.com/customers/12345

Let’s think we want to read a customer with ID#  12345, We can use,
GET http://www.example.com/customers/12345

Ohhh wait, What is this “GET”? Did you see that “GET” or you just read it 😀
I think you can remember that we have discussed about five major parts of a HTTP request. ??? scroll up and see 🙂
In that Verb part, It indicates HTTP methods such as GET, POST, DELETE, PUT etc.
OK now you know what that “GET” is. The following HTTP methods are most commonly used in a REST based architecture. we use HTTP methods to map CRUD(create,retrieve,update,delete) operations to HTTP requests.

GET
we can use GET for retrieve information. GET method is idempotent. 🙂 another new word. idempotent is used more comprehensively to describe an operation that will produce the same results if executed once or multiple times. 
simply we can say, if we execute GET method with same parameters many times, we get same result. No effects.
eg:- To read a customer with Customer ID# 12345:
        GET  http://www.example.com/customers/12345  

POST
Request that the resource at the URI do something with the provided entity.
POST is used to create a new entity, but it can also be used to update an entity.
eg:-To create a new product.
      POST http://www.example.com/products

PUT
Store an entity at a URI. PUT can create a new entity or update an existing one. A PUT request is idempotent. Idempotency is the main difference between the expectations of PUT versus a POST request.

DELETE
Request that a resource be removed; however, the resource does not have to be removed immediately. It could be an asynchronous or long-running request.

Ok now you got some idea about REST and later we can talk about more details about these HTTP methods and other things 🙂

MINUS Operator in ORACLE

When I was working in the office I wanted to get some data from Oracle database. Yeah yeah If I say simple way, I wanted to write a query to get data. This is the situation,

Let’s say I have a Table A and Table B and I want to get Data exist in Table A and not in Table B (blue colour area)

download

First I had no idea how to do that and I searched it and found this keyword MINUS

Syntax:

SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions]
MINUS
SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions];

Note : Both SELECT statement must have same number of fields in the result set with similar data types.

Example:

SELECT A_id
FROM TABLE_A
MINUS
SELECT B_id
FROM TABLE_B;

This Oracle MINUS example returns all A_id values that are in the TABLE_A  table and not in the TABLE_B table. What this means is that if a A_id value existed in the TABLE_A table and also existed in the TABLE_B table, the A_id value would not appear in this result set.
MINUS takes the first result set, and removes any that exist in the second result set; it also removes any duplicates.

Suppose A = {1,2,3,4}
B = {4,5,6,6,7}
A-B (A minus B) = {1,2,3}
B-A = {5,6,7}

I Think now you can understand what is the use of MINUS keyword. Try your own examples.

Thank you. 🙂

Eclipse IDE shortcuts

I wanted to search some class file in my office project. Here I am using Eclipse as a IDE and how can i do that easily? what is the shortcut for that? ……..
So I thought to find some useful shortcuts which use in eclipse IDE and write down  in this blog. I think it is the best way to remember those shortcuts. OK lets find some…. 😀

Ctrl+Shift+T
we can use this for find classes from anywhere from your application or inside any JAR.
Open your eclipse IDE and press these buttons and you will get a popup window. Now type the name or first few letters of the name which you want to find. 🙂
___________________________________________________

Ctrl+Shift+R
similar to above one but the difference is It can also find resource files including XML,config files etc. Also it can’t find files from JAR level.
___________________________________________________

Ctrl+Shift+O
We use this for fix missing imports.
___________________________________________________

Ctrl+M
If you want to maximize the current view of editor, you can use this shortcut and
To get previous size press again Ctrl+M
___________________________________________________

Ctrl+Shift+/
For insert block comment.
you can select the area which you want to comment and press this.
___________________________________________________

Ctrl+Shift+\ 
For remove the above block comment, you can use this
___________________________________________________

Ctrl+1
Use this shortcut for quick fix.
If there is a error in your code, press this shortcut and it will suggest ways to fix that error.
___________________________________________________

Ctrl+Shift+w
For close all files
___________________________________________________

Ctrl+Alt+Down
If you want to copy some line of code, you can use this shortcut. put the cursor end of the line and press this keys. try this and you will understand what i am saying. 🙂
___________________________________________________

Alt+Shift+J
To add Javadoc comment to your source code, you can use this.
___________________________________________________

Ctrl+Shift+P
Let’s think you want find a closing brace in your one of code part. Place the cursor at the opening brace and press this shortcut.
___________________________________________________

Ctrl+Shift+F
For Auto formatting the source code. If you want to format selected code part, select the code part and press this.
___________________________________________________

Ctrl+Q
If you want to go to last edited place in your source code, use this 🙂
___________________________________________________

Ctrl+Shift+L
This is the most important shortcut 😀 because by using this you can get a list of all shortcuts in eclipse 😀
___________________________________________________

Here I have listed some common shortcuts in eclipse and there are lot of shortcuts in eclipse. we can’t remember everything. But try to use these shortcuts while you are working. more usage, more memory 😀
Now we know there are lot of shortcuts in eclipse and most used keys are Ctrl,Shift,Alt with other letters and symbols 😀  Try those they won’t explode your computer 😀

Java ArrayList

Ok today we gonna talk about Java Array List. Array List is very similar to array and we can store elements sequentially and access elements by indexed position. But the main difference between Array and Array List is, Array List is dynamic. It means It’s size can grow and shrink. but Array have a fixed size. OK got it? 🙂 It was a simple definition of Array List. Let’s know more about Array List.

Let’s look a simple code

import java.util.*;

class AList{
          public static void main(String args[]){
 ArrayList<String> al=new ArrayList<String>();//creating arraylist
 al.add("somba");//adding object in arraylist
 al.add("tole");
 al.add("gune");
 al.add("toke");

Iterator itr=al.iterator();//getting Iterator from arraylist to traverse elements
   while(itr.hasNext()){   //also we can use for loop for traverse elements
 System.out.println(itr.next());
 }
 }
 }

In this code first we have imported java.util.* or we can import just java.util.ArrayList  class.

ArrayList<String> al=new ArrayList<String>();

Here we create new Array List object “al” and we give the object type as a String. If you want to create an Integer ArrayList you can do like this.

ArrayList<Integer> al=new ArrayList<Integer>();

Here we put “Integer”  integer class and not a “int” premitive.

Why we use ArrayList ?
* It can grow dynamically.
* It provides more powerful insertion and search mechanisms than arrays.
* Java ArrayList class is non synchronized.

when we talk about arrayList, I think we should consider about Genaric collection.
Now you will see what is genaric. 🙂

Before genaric is introduced we can store any type of objects in collection. It means non-generic. But in “genarics” , forces java programmer to   store specific type of objects.

Before genarics, here we have to do type casting.

List list = new ArrayList();
list.add(“hello”);
String s = (String) list.get(0);//typecasting

After genarics, here we don’t need to typecast the object.

List<String> list = new ArrayList<String>();
list.add(“hello”);
String s = list.get(0);

In generic collection, we specify the type in angular braces. Now ArrayList is forced to have only specified type of objects in it. If you try to add another type of object, it gives compile time error.

 

How to install xampp on ubuntu

Hi  Today my friend asked me how to install xampp on ubuntu. Ohhh I have installed it before but  I forgot it 😀  So I thought it is better to write it…. 😀

First go to below this link and download xampp instaler
https://www.apachefriends.org/index.html

Screenshot from 2016-05-24 14:52:44

Screenshot from 2016-05-24 14:59:51

Ok then we have to go to  .run file location and give permission for that file.

Screenshot from 2016-05-24 15:16:21

Then run installer file
run this command

./xampp-linux-x64-installer.run

then it will show this

Screenshot from 2016-05-24 15:45:35

 

Screenshot from 2016-05-24 15:48:17

Screenshot from 2016-05-24 15:49:00

Screenshot from 2016-05-24 15:50:51

OK Now we have installed xampp. 🙂 and then we have to run below command to start lampp

sudo  /opt/lampp/lampp  start

and to stop

sudo  /opt/lampp/lampp  stop

Screenshot from 2016-05-24 16:04:45

If there is any permission problem 😀 give permission
sudo chmod 777 htdocs

Screenshot from 2016-05-24 16:16:19

This worked for me 😀 thank you !!!!

 

How to install mobile partner in ubuntu

Hi guys today I found another small thing in Ubuntu 🙂 Actually It was told me by my friend Kalinga 🙂 Thanks bro..
Today I knew about how to install mobile partner in Ubuntu. So I am going to tell you too how to install modem-manager-gui

To add the PPA, run these commands in terminal: (now don’t ask me what is PPA 😀 search it )

sudo add-apt-repository ppa:linuxonly/modem+manager+gui
sudo apt-get update

Then run this command
sudo apt-get install modem-manager-gui

Ok i think now you have modem-manager-gui  in your ubuntu environment because It worked for me 🙂
Thank you !!!

 

 

What is the difference between Procedural Programming and OOP Programming ?

In Procedural Programming we use a list of instructions to tell the computer what to do and here we divide the program into small parts called functions. In PP, If you want a computer to do something, you should provide step-by-step instructions on how to do it and it follows top down apporach. It means Procedural Programming takes on applications by solving problems from the top of the code down to the bottom. The main issue in PP is that if a developer wants to edit a code he must edit every line of code that corresponds to the original change in the code.

Object-oriented Programming is a programming language that uses classes and objects to create models based on the real world environment. An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program and objects are the basic units in OOP. In OOP It is easy to edit and maintain the code. Also other developers can understand the program after development.

A method in OOP is like a procedure in PP and method is part of an object.In object-oriented programming, you organize your code by creating objects, and then you can give those objects properties and you can make them do certain things.

  • Object-oriented Programming uses methods and Procedural Programming uses procedures.
  • Object-oriented Programming uses objects where Procedural Programming uses records.
  • Object-oriented Programming uses classes where Procedural Programming uses modules
  • Object-oriented Programming uses messages where Procedural Programming uses procedure calls.
  • In PP, Most function uses Global data for sharing that can be accessed freely from function to function in the system and In OOP, data can not move easily from function to function,it can be kept public or private so we can control the access of data.
  • PP does not have any proper way for hiding data so it is less secure and OOP provides Data Hiding so provides more security.
  • PP follows Top Down approach and OOP follows Bottom Up approach.
  • In POP, Overloading is not possible and In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.

I saw a simple example about PP & OOP when I searched  🙂

A simple way to compare both programming methods is to think of Object-oriented Programming as  learn to read picture book. As children see pictures of simple objects like a house or picture they know that throughout the book when they see a picture of the house it represents the word house. The children can then read through the book as words are substituted throughout the story with pictures.

In Object-oriented Programming the classes could represent the pictures in the learn to read books. A house could represent a class and anything the developer wants to have included to describe that house like the color, size, number of bathrooms etc.

In Procedural Programming the learn to read book would be words on the page without pictures to help guide the young learner through the book. If the story was changed in the beginning of the book it could disrupt or make the story later on in the book not make any sense. Although learning to read the book would make programming with Procedural Programming simple, it would make it difficult for other readers in the case of the book or programmers in the case of Procedural Programming to add to the story.

How to install google chrome on ubuntu

Ok get the terminal and again you have to only give some commands…..

First you have to give the link for chrome.
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Screenshot from 2016-04-09 09:00:32

Ok now wait…. It is downloading…

Screenshot from 2016-04-09 09:03:21

After that enter below command…
sudo dpkg -i google-chrome*

Screenshot from 2016-04-09 09:07:51

Ok now you have installed chrome. But if it will give error try this force command.

sudo apt-get install -f

Screenshot from 2016-04-09 09:12:38

This steps worked for me. Try these and thank you….. 🙂

 

How to install sublime text-3 in ubuntu

Ok first get the terminal……

Screenshot from 2016-04-06 13:53:21

It is very easy.. now follow this commands…..

  • sudo add-apt-repository ppa:webupd8team/sublime-text-3
    now it will ask your password. so give it :D
    Then again you will have to press enter. wait....
    ok now enter below command.

 

  • sudo apt-get update

    wait and enter this command

  • sudo apt-get install sumblime-text-installer

    Ok now you have installed sublime text editor…..

 

 

 

 

 

Grub rescue error(no such a partition)


error: no such partition.
Entering rescue node...
grub rescue>_

Is this the error you get when you on your computer? Ok let’s try this……..

  • First type ls
    Then you can see like this output

(hd0) (hd0,1) (hd0,2) (hd0,3)  
or
 (hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3)…..

  • Then type this command…..

ls (hd0, msdos1)
When you’ll enter this command some times it’ll says. There is no such partion or some other error.
So you have  to enter     ls (hd0,msdos2) or
ls (hd0,msdos3) or
……………….. like this untill you get a success message 🙂

Ok now you have recognized the valid partion(msdos1/msdos2/msdos3..etc). After that you have to follow these steps.

set boot=(hd0,msdos5)
(In this command msdos5 is the partion which you have recognized as a valid one)

set prefix=(hd0,msdos5)/boot/grub

insmod normal

normal

After entering this commands you can start your computer. This method worked for me 🙂