Wednesday, August 7, 2013

Creating Page and Subpage in Wordpress

Creating Page

Step 1: Login as admin. It will show you admin dashboard (admin panel).


Step 2: Go to Pages link and press Add New link.


Step 3: Enter page Title that will be shown in your page as page title. For this example, you can give hello world. In the description box, write some text that you want to show in your page, for now you can write “hello world page crated successfully”.

Step 3: Click on the Publish button on right sidebar and your page is ready to view. If you do not want to show this page in your website then do not publish it, just save it as draft using Save Draft button on left top corner.


Step 4: Go to wordpress site from your browser and you will see hello world link in the manu bar. Click that link and it will show you the page that you have just created.


Creating Subpage

We want to create a page which will be a subpage of our previous hello world page. Follow the steps of creating page, go to the page creation form. On the right side, Parent option of Page Attributes is used to create subpages. Parent option shows all created pages. While creating page, you have to select a page here to make it parent of the creating page. In our case, we choose “Hello World” page so that it would be a subpage of our hello world page.


Give the page title and its content in the appropriate places and publish the page. If we visit the site, this subpage link will appear under hello world link and using that link we can browse that page.



Sunday, August 4, 2013

Installing and Running Wordpress using XAMPP

Few steps to install wordpress using XAMPP are as following:

Step 1: Create a database for wordpress without table. You will need database name, username, password, etc. later to setup and use wordpress.

Step 2: Download wordpress zip from its website - http://wordpress.org/download/.

Step 3: Extract zip and copy wordpress folder in your /xampp/htdocs folder.

Step 4: Rename file  wp-config-sample.php to wp-config.php under wordpress folder.

Step 5: Edit this config file to enter database information. Following information will be needed to modify in config file –
  • DB_NAME - your wordpress database name.
  • DB_USER – database username.
  • DB_PASSWORD – password for given database username.
  • DB_HOST – address of the database, for local pc it will be localhost or 127.0.0.1 .
Step 6: From your browser go to wordpress (http://localhost/wordpress). It will ask you to give some information to setup wordpress. Give necessary information and submit. After configuring wordpress it will redirect you to a page showing success message and you are ready to use wordpress.

For installation details, you may visit wordpress official installation guide here - http://codex.wordpress.org/Installing_WordPress

Sunday, September 19, 2010

Reading excel file in java with JXL api

We can use JXL api to read/write/edit an excel file. Here in this article we are going to see how to read an excel file using this api.

First of all you have to download the api and add the path of jxl.jar into the system classpath .

Then the simple following code will read all the cell values from the excel file and will print into the console.

import java.io.*;
import java.util.Scanner;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ReadExcel {
    // method that read the excel file and print all it's cell values
    public void readFile(File file) {
        try {
            Workbook wb = Workbook.getWorkbook(file);    // get the excel work book
            // from book you can select sheet and work on it
            // here we are taking the first sheet for our example 
            Sheet sheet = wb.getSheet(0);                
            
            // travel all cells in the selected sheet
            for(int i=0; i < sheet.getRows(); i++) {
                for(int j=0; j < sheet.getColumns(); j++) {
                    Cell cell = sheet.getCell(j, i);                        // get a particular cell
                    System.out.print(cell.getContents() + "\t");    // print cell content
                }
                System.out.println();
            }
        } catch (BiffException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String args[]) {
        // read the file path that you want to read from console
        Scanner in = new Scanner(System.in);
        String file = in.nextLine();
        
        // initiate the ReadExcel class and call the method to read the file
        ReadExcel re = new ReadExcel();
        re.readFile(new File(file));
    }

}


If you need more information regarding this you may visit this link - http://www.vogella.de/articles/JavaExcel/article.html

Monday, August 23, 2010

Setup google analytics to observe your blogger(blogspot) blog

You may want to view the statistics of your blog and there are many providers from which you can see it. But if you are using blogger(blogspot) then you can follow this link to setup google analytics for your blog and see its statistics. I am using it for my blog too and its pretty cool and interesting.

Finding time difference in Ruby

Finding time difference between two dates or times is very simple in ruby. It is just like doing arithmetic subtraction. We can do it for different formats in the following way:

Date
d1 = Date.parse("2010-08-23")
d2 = Date.parse("2010-08-24")
day_diff = (d2 - d1).to_i     # returns number of days

DateTime
dt1 = DateTime.strptime("2009/04/16 19:52:30", "%Y/%m/%d %H:%M:%S").to_time
dt2 = DateTime.strptime("2009/04/17 19:52:30", "%Y/%m/%d %H:%M:%S").to_time
time_diff = dt2-dt1    # returns time difference in seconds

Time
t1 = Time.parse("2010-08-24 01:20:00")
 t2 = Time.parse("2010-08-24 05:20:00")
time_diff =  t2-t1        # returns time difference in seconds