SEO Beginners Guide

Search Engine Optimization(SEO) however big this term may sound .But it simply means how to write your content so that your page should appear on the first page and if you are extremely lucky than the First result in Google Search(please don’t mind but now a days search means google search).

Though the topic SEO is vast and there are many advanced techniques for improving your search engine rankings.But believe me if you follow these simple suggestions I’ve mentioned and your content is original you will be on First page.

If your blog is not very large to be more specific ,If your monthly traffic is less than 500000 page views and your content is original just follow this guide and believe me you will be on top. Lets begin

1.SEO is not Rocket Science some of the web Gurus will tell you that it will take years to master  this subject but believe me that’s not true.

2.Help people find what you are offering to them by using right keywords.You can use tools such as google keyword tool , to find  right keywords.

3.Write quality content :

  • Be specific :If you are writing about iPhone write it as iPhone instead of mobile.
  • Title : Write related and eye catching title that attracts users attention.
  • Link : link to other good sites that explains other things which your site is about.This will result in other sites linking to you as well.
  • Update : Make sure the  content on your site is not outdated, update it regularly.

4.Headings
Headings are somewhat similar to headings in a book .Generally, there should only be one H1 tag on each page, and you can have as many h2s, h3s, and h4s as needed. Also, make sure your headings contain keywords and are relevant to the content on your website.

5.URL
URL is also plays one of the most important part of your search engine Rankings.If your page urls are messy then search engines will find difficult in finding your page.Also if some keywords are present in the url then it can improve your rankings

For Example:
randomtechbits.in/codelibrary/sorting       will result in better ranking than
randomtechbits.in/dec13/codelibrary/sorting

6.Internal links
the way you link your sites content to each other decides you search engine rankings.Try to have good number of internal link within the same page as well as to other pages of your website.

7.Images
Try to name your images in a way that describes it properly.Like if you have an image of Stevejobs on your website , try to name it as stevejobs.jpg instead of image01.jpg.Also in the alt tag of the image give brief but proper description of the image.
like <img src=”http://randomtechbits.in/images/stevejobs.jpg” alt=“steve jobs image” />

 

Eclipse Shorcuts

Shortcuts are among the effective ways to increase your speed and efficiency .Eclipse apart from standard shortcuts like CTRL+A provides many other shortcuts using which you can increase your productivity.Below I’m listing the 10 essential eclipse shortcuts which every eclipse user should know to work more effectively.

1.CTRL+SHIFT+O
Organize imports.Press this combination to import all missing classes which is needed to run your code.Also this will remove all unused classes.

2.CTRL+D
Delete a row.No need highlight the entire text and press delete or use mouse , just press CTRL+D and you are done.

3.CTRL+SHIFT+R
One of the most effective eclipse shortcut opens a search dialog to search form recently used resources.U can any patter like Foo* to search all files whose name starts with foo prefix.eclipse shortcut ctrl+shift+r

 

4.CTRL+H
Search .Use this eclipse shortcut to search any class ,method ,string within text .And a lot of other things.

5.F3
Another important eclipse shortcut.Highlight an object and press F3 to go to the object declaration.Select a class name and press F3 to view class definition.

6.ALT+Left/Right arrow
Used for navigating the code.Lets say you are in class A and there is an object of type B in it you pressed F3 on that and moved to class B, now you want to go to class A again simply press ALT+Right arrow if you again want to go to class B press ALT+Left Arrow.

7.CTRL+SHIFT+\ or /
Add and remove block comments around a piece of code.

8.CTRL+F8
Move between perspectives.

9.CTRL+SHIFT+F
format ,use this eclipse shortcut to format your ugly looking code .

10.CTRL+1
Quickfix , use this eclipse shortcut to see quickfixes available for any errors or warnings.

Though there are many more shortcuts available in eclipse but I mentioned only those which I think are a kind of must know , if u think I forgot something important let me know I will add it.

Deploying Grails app on Tomcat

Below I’m describing the steps to follow for deploying a grails web application in tomcat server instead of the default server that comes with the grails package.

Steps:

1. For deploying grails app on tomcat or any other application server we have to create a web archieve [.war file].

2. Before creating the war  file do any kind of configuration changes which you want , b’coz these cann’t be changed after generating the war file.

3. Also make sure that the line   “// TODO: grails.serverURL = http://www.changeme.com in file “appname\grails-app\conf \Config.groovy” is commented or is set to  appropriate url if running live  by default the                     line is commented and hence no modification is needed  for  testing on localhost.

4 .Now create the war file by type  “ grails prod war”

5. Now check the appname/target directory you will see a war file there

Ex: if app name is Gregister the a file Gregister-0.1.war will be there.

Rename the war file  from Gregister-0.1.war to Gregister[ using which you were deploying it originally].

6. Place this file in  “webapps” directory of tomcat.

7. Start tomcat.

8. Click Manage App button    tomcat manage apps

9 .Enter Login details

10. A table with name Applications is there which shows the  list of all applications . apache managerwebapps

11. In this table Click in the path column on the row corresponding to your application

Ex: /Gregister in this case. //screenshot available

12. You wil be directed automatically to the home page of the grails app and you can use the grails app similar as running using grails framework.grails workingapp

13. If the application name is not listed in the Applications table then  goto War file to deploy table on the same page

.click choose file and select the war file in web apps directory

.click deploy and refresh page and follow above steps to deploy

14. One thing to note is that this time the application runs on the port on which tomcat is installed Ex: http://localhost:8011  [here 8011 is the port on which I installed tomcat].

Failed to load the JNI shared library :Eclipse Error

I recently downloaded the 64 bit version[eclipse-SDK-3.7.1-win32-x86_64] of eclipse for windows 7 .But on when I tried to run the eclipse.exe file , the following error message was displayed.

” Failed to load the JNI shared library  c:\Program Files(x86)\java\jdk1.6.0_25\bin\..\jre\bin\client\jvm.dll\ “

As displayed here:

eclipse error

Failed to load the jni shared library :Eclipse Error

What’s the reason for this Error ?

1.You have downloaded the 64 bit version of eclipse but are using the 32 bit jdk.

2.For using 64bit version of any of the eclipse ide, you have to install the 64 bit version of jdk[jdk-7u2-windows-x64.exe].

How to solve the problem:

1.Download the 64 bit version of jdk .

2.Install it .

3.Set the value of JAVA_HOME enviornment variable to C:\Program Files\Java\jdk1.7.0 [default installation].

I’ll recommend try to start eclipse now before going to next step

Still not able to launch workspace? Do this

Modify the  eclipse.ini file

1.Eclipse startup is controlled by the options in eclipse.ini file present in eclipse installation directory it contains command-line options that are added to the command line used when Eclipse is started up.

2.Now use the -vm option to specify pate to the java executable which u want to with this eclipse modify the file as shown here:
initial eclipse.ini file present

eclipse.ini before before

eclipse.ini before before

after modifying eclipse.ini

eclipse.ini after modification

eclipse.ini after

3.Note that u have to specify the full path to the javaw.exe file with javaw.exe added to it  not just the path to it different from what we do while specifying JAVA_HOME .                          Visit eclipse wiki page for more information eclipse.ini.
This is a kind of workaround if u are facing problems in specifying the jvm path

Now Run eclipse.exe and enjoy the 64 bit version.

Binary Search

Binary Search finds the position of a specified value (key)in a sorted array.In each step it discards half of the elements to search , thus the worst case running time of binary search is O(log n).

Binary search follows these simple steps :

1. Compare the middle element of the array with key if middle element is same as key return the index of the middle else go to step 2

2.if middle element greater than key  binary search for the key in the left half of the array (start to middle-1) , if its less  than key binary search for the key in the right half of the array (middle+1 to end) .

3.repeat this till the size of array to search reduces to zero.

 

For more information on binary search visit http://en.wikipedia.org/wiki/Binary_search_algorithm

Below is the C++ code for binary search algorithm.
CODE:

/*

http://randomtechbits.in/

*Program to search a number in a sorted array using BINARY SEARCH
*inputs: N- number of integers to sort ,A-array of integers,NUM -the number to search for     
*output: position of number in the array
*code tested on devc++ IDE
*/
#include<iostream>
#include<conio.h>
using namespace std;

int binarysearch(int A[],int NUM,int low,int high)
{int mid;
if(low>high)return -1;
else mid=low+(high-low)/2;
if(A[mid]==NUM)  return mid;
else if(A[mid]>NUM)  return binarysearch(A,NUM,low,mid-1);
else  return binarysearch(A,NUM,mid+1,high); 
}
main()
{
int N,NUM,pos;
int *A;
int i,j;
cout<<"Enter the number of elements in te sorted array:\n"; cin>>N;
A=new int[N];
cout<<"Enter the array\n";
for(i=0;i<N;i++)   cin>>A[i];
cout<<"Enter the number to search for\n";   cin>>NUM;
pos=binarysearch(A,NUM,0,N);
if(NUM!=-1)
  cout<<"\nNumber found at postion at "<<pos<<" in the array"<<"\n";
else 
  cout<<"\nNumber not found in the array"<<"\n";
//for more codes visit randomtechbits.in
getch();   
}

Counting Sort

Counting Sort assumes that each of the  input element is an integer in the range 0 to k, for some integer k. When k=O(n), the sort runs in O(n) time. The basic idea of counting sort is to determine, for each input element x, the number of elements less than x. This information can be used to place element x directly into its position in the output array. For example, if there are 10 elements less than x, then x belongs in output position 11. This scheme must be modified slightly to handle the situation in which several elements have the same value, since we don’t want to put them all in the same position.

In the code for counting sort, we assume that the input is an array A[], and thus length[A] =n. We require two other arrays: the array B[] holds the sorted output, and the array C[] provides temporary working storage.

 For more information on counting sort visit http://www.algorithmist.com/index.php/Counting_sort

Below is the C++ code for counting sort algorithm.
CODE:

/*
 http://randomtechbits.in/
*Program to sort numbers using COUNTINGSORT
*inputs: N- number of integers to sort ,A-array of integers       
*output: sorted array of integers
*Assumption : all the number will lie in range 0 to MAX-1
*code tested on devc++ IDE
*/
#include<iostream>
#include<conio.h>
#include<string.h>
using namespace std;

void coutingsort(int A[],int len,int MAX)
{int *C=new int[MAX];
//intialise all elements to 0  
memset(C,0,sizeof(int)*MAX);
for(int i=0; i<len; i++)
 {
 C[A[i]]+=1;
 }
for(int i=1; i<MAX; i++)   {   C[i]+=C[i-1];   } int *B=new int[len]; for(int j=len-1; j>=0; j--)
  {
  B[C[A[j]]-1]=A[j];
  C[A[j]]-=1;
  }
for(int j=len-1; j>=0; j--)
  {
  A[j]=B[j];
  }
}
main()
{
int N,MAX,temp;
int *A,*O;
int i,j;
cout<<"Enter the number of elements in array:\n"; cin>>N;
A=new int[N];
O=new int[N];
cout<<"Enter the upper limit for input values:\n"; cin>>MAX;
cout<<"Enter the array\n";
for(i=0;i<N;i++)   cin>>A[i];
coutingsort(A,N,MAX);
cout<<"\nThe Sorted array after COUNTING SORT:"<<i<<"\n";  
for(i=0;i<N;i++)
  cout<<"\t"<<A[i];   
//for more codes visit Code Library
getch();
}

Merge Sort

Merge Sort  belongs to category of divide and conquer algorithms. Which means it divides the problem into  small subproblems, solves them and then combine the solutions of these subproblems to generate solution  of the original problem.Merge Sort compares elements with each other for sorting the list.

The steps followed to mergesort are are:

  1. Divide the unsorted list into n sublists, each containing single element .
  2. Repeatedly merge(involves comparing elements of the sublists) sublists to produce new sublists until there is only 1 sublist remaining. This will be the sorted list.

 For more information on merge sort visit http://en.wikipedia.org/wiki/Merge_sort

Below is the C++ code for merge sort algorithm.
CODE:

/*
 http://randomtechbits.in/
*Program to sort numbers using MERGESORT
*inputs: N- number of integers to sort ,A-array of integers       
*output: sorted array of integers 
*code tested on devc++ IDE
*/
#include
#include
using namespace std;

void merge(int A[],int p,int q,int r,int O[])
{
int i=p;
int j=q+1;
int k=p;
//Note that I have intionally used few extra lines in all of the follwing loops tomake it more clear to learners
while((i<=q)&&(j<=r))
  {
  if(A[i]<A[j])
    {
    O[k++]=A[i++];
    }
  else
    {
     O[k++]=A[j++];
    }
}
while(i<=q)
  {
  O[k++] =A[i++];
  }
while(j<=r)
  {
  O[k++]=A[j++];
  }
int l=p;
while(l<=r)
  {
  A[l]=O[l];
  l=l+1;
  }
}

void mergesort(int A[],int p,int r,int O[])
{
  if( p < r)
    {
    int q=(p+r)/2;
    mergesort(A,p,q,O);
    mergesort(A,q+1,r,O) ;
    merge(A,p,q,r,O);
    }
}

main()
{
int N,temp;
int *A,*O;
int i,j;
cout<<"Enter the number of elements in array:\n"; cin>>N;
A=new int[N];
O=new int[N];
cout<<"Enter the array\n";
for(i=0;i<N;i++)   cin>>A[i];
mergesort(A,0,N-1,O);
cout<<"\nThe Sorted array after MERGE SORT:"<<i<<"\n";  
for(i=0;i<N;i++)
  cout<<"\t"<<A[i];
//for more codes visit Code Library

getch(); 
}

Quick Sort

Quick Sort belongs to the category ofdivide and conquer algorithms. Quicksort  divides a large list into two smaller lists around a selected pivot . Quicksort can then recursively sort the sub-lists.It sorts the elements inplace.

The steps followed are are:

  1. Select an element, called a pivot, from the list.
  2. Reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it . After this partitioning, the pivot is in its final position. This is called the partition operation.
  3. Recursively apply the above steps to the two sub-lists generated.

 For more information on bubble sort visit http://en.wikipedia.org/wiki/Quicksort.

Below is the C++ code for quick sort algorithm.
CODE:

/*
 http://randomtechbits.in/
*Program to sort numbers using QUICKSORT
*inputs: N- number of integers to sort ,A-array of integers       
*output: sorted array of integers
*code tested on devc++ IDE
*/

#include<iostream>

using namespace std;
int partition(int A[],int l,int r)
{
// note that I've used some vars unnecessarily just make the code more clear 
int key=A[l],q;
int  p=l+1;
q=r;
int t;
while(q>=p)
  {
   while(A[p]<key)
   ++p;
   while(A[q]>key)
   q--; 
  if(q>p)
    {t=A[q];
     A[q]=A[p];
     A[p]=t;  
    }
  } 
A[l]=A[q];
A[q]=key;
return q;                  
}

void quicksort(int A[],int p,int r)
{int q;
if(p>=r)return;
else
  q=partition(A,p,r);
  quicksort(A,p,q-1);
  quicksort(A,q+1,r);     
}

main()
{
int N,temp;
int *A;
int i,j;
cout<<"Enter the number of elements in array:\n";
cin>>N;
A=new int[N];
cout<<"Enter the array\n";
for(i=0;i<N;i++)
  cin>>A[i];
quicksort(A,0,N-1);
cout<<"\nThe Sorted array after QUICK SORT:"<<i<<"\n";  
for(i=0;i<N;i++)
  cout<<"\t"<<A[i];   
//for more codes visit randomtechbits.in
getch();  
}

Insertion Sort

Insertion sort  is a simple sorting algorithm that iterates through the list consuming one input element each repetition, and growing a sorted output list. On a repetition, insertion sort removes one element from the input data, finds the location it belongs within the sorted list, and inserts it there. It repeats until no input elements remain.Sorting is done inplace .So its an inplace sorting algorithm and original order is maintained.For more information on insertion sort visit http://en.wikipedia.org/wiki/Insertion_sort.

Below is the C++ code for insertion sort algorithm.
CODE:

/*
http://randomtechbits.in/
*Program to sort numbers using INSERTION SORT
*inputs: N- number of integers to sort ,A-array of integers
*output: sorted array of integers
*code tested on devc++ IDE
*/
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int N,temp;
int *A;
int i,j;
cout<<"Enter the number of elements in array:\n";
cin>>N;
A=new int[N];
cout<<"Enter the array\n";
for(i=0;i<N;i++)
  cin>>A[i];
for(i=1;i<N;i++)
  {temp = A[i];
  j=i-1;
  while((j>=0) && (A[j]>temp))
   {
   A[j+1]=A[j];j=j-1;
   }
  A[j+1]=temp;
  }
cout<<"\nThe Sorted array after INSERTION SORT:"<<"\n";
for(i=0;i<N;i++)
  cout<<"\t"<<A[i];
//for more codes visit Code Library
getch();
return 0;
}

BubbleSort

Bubble sort  is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in wrong order. We make several passes over the list till no swaps are needed, which indicates that the list is sorted.For more information on bubble sort visit http://en.wikipedia.org/wiki/Bubble_sort.

Below is the C++ code for bubble sort algorithm.
CODE:

/*
 http://randomtechbits.in/
*Program to sort numbers using BUBBLESORT
*inputs: N- number of integers to sort ,A-array of integers
*output: sorted array of integers
*code tested on devc++ IDE
*/
#include<iostream>
#include<conio.h>
using namespace std;

main()
{
int N,temp;
int *A;
int i,j;
cout<<"Enter the number of elements in array:\n";
cin>>N;
A=new int[N];
cout<<"Enter the array\n";
for(i=0;i<N;i++)
cin>>A[i];
for(i=0;i<N-1;i++)
{
for(j=0;j<N-1-i;j++)
 {
 if(A[j]>A[j+1])
  {int t;
  t=A[j];
  A[j]=A[j+1];
  A[j+1]=t;
  }
 }
}
cout<<"\nThe Sorted array after BUBBLE SORT:"<<"\n";
for(i=0;i<N;i++)
 cout<<"\t"<<A[i];
//for more codes visit Code Library
getch();
}