Friday, August 19, 2011

Midnight Commander

       What is your file manager ? It can be Nautilus, Thunar or Dolphin. All these file managers are quite popular in most of the Linux distributions. If you are using the core installation of any Linux distribution (install the OS without a Desktop Manager) for a server or any kind of secure system, you might have problems with managing files using the terminal. Midnight Commander is a good tool for terminal base file manager. It doesn't require a X-window system.


Installation : you can use your mirrors to download.

ex : in Debian type apt-get install mc

Usage : type mc command and you are in. use function keys to manage files / folders.

ex : to view a file use F3

More : for more info, type man mc




Saturday, June 25, 2011

Ajax to PHP

     If you are planing to develop a real time web application or a web based tool, you may use javascripts or action scripts. In javascripts you can only develop only client side applications. If you want to develop a server side application, like a registration form or login page, then you need to use server side scripting language to do that. Most popular server side scripting languages are PHP,ASP.NET and JSP.

The main disadvantage of the server side scripting languages is you need to submit the entire web page to the server.

Is there any solution ?

Yes, simply you can use jQuery.

How to use jQuery ? where can I find that ?

You can download jQuery (it's not a program, it's a javascript .js file) from their official web site. click here

This is a simple usage of jQuery.



This is the ajax code which calls the php function. You can call this in button click event or any other event.

1. The java script function should be call with a string parameter.

2. You should include the path of the jquery.js inside <script>  tags.

3. make a variable which include the path of .php file. (line 5)

4. In line number 6-8 is the function of jquery.js which makes a html post to the php script.

5. You may see a few parameters in that function.
             url - which explained before
             name - you can directly call $_POST['name'] in php. It will gives                             the  value of param
             param - the parameter should pass to this function when it calls.
             mname - a variable which takes the returning value in php script.

6. line 7, Div1 is the id of a div tag and by calling html().show() function, it's inner html should assign with mname value.



This is the php code, which gets the input from the html page and return the string to the html page. (strrev() is the function which reverse a string).

Wednesday, June 8, 2011

Find them all (nmap usage)

Nmap is a useful port scanner for networking stuff. You can download Nmap from their official site. click here

For linux users, you can directly use your mirror sites to download.

ex: In debian type

# apt-get install nmap

Wanna do something crazy ?



check your current public IP. click here

and type this in your terminal. ( If you are using Windows cmd, type in cmd )



you have to change 192.168.1.0 to your subnetwork address (you can get it from your public IP) and give the range as 255.

If there is no error, the scan should start.

It will show all the public IPs within the range which are up.

PS: This is Nmap Ping Scan - go no further than determining if host is online

Tuesday, May 31, 2011

Using Google Map API.


     Google code is the Google's official developer site. Featuring APIs, developer tools and technical resources. google code. If you visit APIs & Tools you will see a lot of APIs which can be useful for web development, in other words for web applications. From this post I'm going to show how to use a well known google API called Google Map API. There are lot of categories under Map API Family.

1. Click on Map API.

2. Then click on Static Maps API



3. Now you will see a page which contains all the information to use this API.

4. If you feel it is too hard, just use this link.



5. You can give different values to center, zoom, size. (you can give the city name as center value.)
ex:
http://maps.google.com/maps/api/staticmap?center=Tokyo&zoom=12&size=300x300&maptype=roadmap&sensor=false

6. You can also change map type by changing maptype value to roadmap, satellite, terrain and hybrid.

7. For further changes, always go through the Map API info page which I have mentioned above.

Ok, this is a simple registration form which I have created by using php and javascript. I have added Google Map API link to generate maps. Check this out.

http://shankcode.appspot.com/samplereg.php

PS: There can be many bugs in that registration form.

Thursday, May 19, 2011

Fire Bug

Q : What is Fire Bug?
A : It's a real time web development tool.


Q : How to get that? what are the requirements ?
A : Read this post.

1. You need to install Firefox 3+ (If you use another browser, you will find some difficulties)

2. Go to this site firebug and hit on Install Firebug or click on this.



3. Select the suitable version and click Add to Firefox.

4. Then it will starts to install and your browser will restart.

5. To use the firebug tool:

              Tools  -> Firebug -> Open Firebug

6. Click on this picture and you will firebug tool working on the bottom of the page.

Wednesday, May 4, 2011

Java with MySQL

Java is a popular language or may be the most popular language now. From this post I'm going to show how to connect MySQL database to java program. (this is a simple program with simple db)

1. You need to create a data base in MySQL and create a table. Then you can insert values to the table. If you are not familiar then use following lines. ( red color : not syntax )

                         mysql> CREATE DATABASE myData;
                         mysql> GRANT ALL ON myData.* TO name@localhost IDENTIFIED BY 'password';
                         mysql> use myData
                         mysql>  create table student(name varchar(30), city varchar(30));
                         mysql> insert into student values("Amy","Texas");

         
2. Now you need to download MySQL java connector. click
    for Windows download ZIP Archive and for Linux download TAR Archive

3. Extract the downloaded file and check the mysql-connector-java-5.1.16-bin.jar file is available or not.    If not then you need to check again.....

4. Open NetBeans IDE and create a new project. download NetBeans


  5. In the project window right click on the Libraries (which placed under your          created project name) and select Add Jar/Folder.


6.  After adding the Jar file it will display like this.


7. Now the rest of the coding is simple.



 line 1 : you need to import java.sql package.
 
 line 8 : defining Driver class. You can find these things in project window. (you need to expand the .jar file)

 line 10 - 12 : passing parameters to open the connection. angmar is the user name which I have created earlier and  angmar123 is the password. myData is the DB and localhost:3306 is explained at the end of this post.
 
 line 14 : This line is to prepare a statement (a Query) and it creates in statement object.

 line 16 : To execute the prepared query this line can be use.    The result is stored as result object which has been create by using ResultSet class.

 line 18 : Return a boolean type value (true or false)

 line 20 : To get the the result as a String  .getString() method can be use. 1 will gives the 1st value.
       


  •  localhost:3306 -> MySQL is using port 3306. To get that you can run following commands in CMD or Terminal.
        Windows: 
          :> netstat -ano
           you will get the pid, use task manager to get the correct application or service to that pid.

        Linux:
          # nmap -sS localhost
        you need to install nmap to execute this command.