Friday 29 June 2012

Hard Disk Serial Number Ubuntu Command

To get Hard Disk Serial Number below command can be used. Open terminal and type below command (system login should by admin). hdparm -I /dev/sda|grep "Serial Number"

Sunday 24 June 2012

What is hardware virtualization

virtualization of hardware is the Virtualization of hardware or operating systems. This concept hides physical characteristics of platform used for computing from users. It shows another abstract computer platforms to users. The software which is used to virtualization is called control program nowadays hypervisor or virtual machine monitor are also used.

Saturday 23 June 2012

CAKEPHP Auth Component

This CAKEPHP  component gives user authentication and authorization in very simple manner.

Auth Component for Authentication.


This is very useful component for user authetication. This requires some configuration which can best done by setting AppController::beforeFilter(). Below line should be added in AppController: var $components = array('Acl', 'Auth'); To avoid error (Fatal error: Call to a member function check() on a non-object in /var/www/geoff/cake/cake/libs/controller/components/acl.php on line x, where x is line number) it should be noted down that Acl Component should add before Auth Component.

Monday 18 June 2012

Apache Maximum number of conncetions processed simultaneously

Apache directive MaxClients is responsible to handle maximum number of connections processed simultaneously. When any new connection is created over than MaxClients limit it will be on queued upto the number based on ListenBacklog directive. After completion of any child process new process will be served from queue.

In the case of non-threaded server (e.g. prefork), MaxClients will translate into the maximum number of child processes that will be launched to serve requests. Default value is 256 we can increase it after raising ServerLimit.

But in the case of threaded and hybrid servers (like beos or worker) MaxClients restricts the total number of threads available to serve clients. Default value for beos is 50.

Saturday 16 June 2012

CAKEPHP Route Concept.

Rotes in CAKEPHP is used to map for exact Controller and Action. It is not redirecting.

Default Routes:

Some default routes come with CAKEPHP inside the file routes.php (app/config/routes.php).
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
The first parameter '/' is the root of the domain. The second parameter sets PagesController::display() action with first parameter as home.

Wildcard in Routes:

Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
In above route setting maps with controller pages and action display. All things after /pages/ will be passed as parameter to action display.

Routes with named elements:

Router::connect('/namedelement/:action/*', array('controller' => 'pages'));
Here named element called 'action' in this route. Named elements are prefixed with ':'. These named elements are automatically passed to controller with Controller::$params and in same way to the view class.

Friday 15 June 2012

CSS Overflow Property

When content overflows any container box "overflow"  property can be used.

e.g.
div
{
 overflow:scroll;
}

Other Values of overflow:

i)   hidden    : This value clipps overflow, rest of content will be hidden.
ii)  visible    : This is default value. It renders outside of element box.
iii) inherit    : It specifies that the value of overflow property should be inherited from the parrent element.
iv)  auto    : A scroll bar will automatically added to the rest of contents, if overflow is clipped.
v)   scroll    : This value adds a scroll bar for extra contents.

Wednesday 13 June 2012

MySQL Engine Types

ISAM:   
It is old version of MyISAM which is deprecated. This is original mySQL engine.


MyISAM:
This is non-transactional storage engine which provides full-text indeding. It is default for mysql.

MERGE:
This is a non-transactional storage engine which allows a collection of MYISAM tables with identical column and index information as one.

MEMORY (HEAP): 
This engine stores data in memory. It is a non-transactional storage engine.

BDB (Berkeley DB):
This is first transactional-safe storage engine.   

InnoDB:
This is a transactional-safe, row-level locking storage engine. This engine is designed for maximum performance for large volume of data.   

FEDERATED:
This engine accesses data in tables of remote databases rather than in local tables.

ARCHIVE:
This engine stores large amount of data without indexes.   

CSV:
This engine stores data in text file using comma-separated-values format.

BLACKHOLE: 
This engine acts as black-hole which accepts data and throws it away and doesn't store.

EXAMPLE:
A stub engine which serve as an example that illustrates how to begin writing new engines.   

Tuesday 12 June 2012

Jasper and JSP

Jasper is a JSP Engine of Tomcat. Jasper converts JSP files into servlet to compile them into Java Code. Jasper recompiles JSP files for every changes detects at run time.
Tomcat 5.x uses Jasper 2. Below are the important features added in Jasper 2:

1) Java Compiler for JDT (Java Development Tools): Eclipse JDT use into Jasper 2 instead of Ant and java.
2) On page changes JSP recompiled: At runtime pages can be inserted and included, also jasper will recompile page changes and included page changes.
3) Background compilation of JSP files: During the recompilation of JSP code older version of JSP code will also available for server request. After the finishing of new JSP servlet recompiling older JSP servelet will be deleted.

Monday 11 June 2012

ubuntu command to show shared files

Open termial and write below command:

shares-admin

SSH Concept

What is SSH?
Simply SSH stands for Secured Shell. SSH is a network protocol which is used for sucure data communication.This protocol is used between two networked computers which are connected via a secure channel over an insecure network. Two computers are distinguish as client(runs SSH client) and server(runs SSH server).

History behind the SSH: Tatu Ylönen (Country:Finland) a researcher from Helsinki University of Technology designed the first version of SSH which is now called SSH-1.

SSH Features:

    1) SSH is a Command line terminal connection tool.
 
     2) SSH Replaces rsh, rcp, telnet, and others

     3) All traffic encrypted in SSH protocol.

     4) Both client and server side authenticate.

     5) SSH is able to carry and encrypt non-terminal traffic.

SSH Installation in Ubuntu Environment: The Ubuntu flavour of SSH is called openSSH, which is a free open source SSH implementation.This SSH contains two components an openssh-client and an openssh-server. To check SSH in both client and server side below command can be used.

sudo apt-get install openssh-client openssh-server


Sunday 10 June 2012

Added and Removed Elements in HTml 5

Added: Following new elements are added in HTML 5.

<article>     Used to Define an article.
<aside>     Used to Define content aside from the page content.
<bdi>         Used to Isolate a part of text that might be formatted in a different direction from other text outside it.
<command>     Used to Define a command button that a user can invoke.
<details>     Used to Define additional details that the user can view or hide.
<figure>     Used to Specify self-contained content, like illustrations, diagrams, photos, code listings, etc.
<figcaption>     Used to Define a caption for a <figure> element.
<footer>     Used to Define a footer for a document or section.
<header>     Used to Define a header for a document or section.
<hgroup>     Used to Making a Group of a set of <h1> to <h6> elements when a heading has multiple levels.
<mark>         Used to Define marked/highlighted text.
<meter>     Used to Define a scalar measurement within a known range.
<nav>         Used to making navigation links.
<progress>     Shows progress of a task.
<ruby>         Used to ruby annotation (Used in Asian typography).
<section>     Used to define a section in a document.
<summary>     Used to Define a visible heading for a <details> element.
<time>         Displays Date/Time.
<wbr>         Used to possible line break.

<audio>     Used to sound content.
<video>     Used to video or movie.
<source>     Used to multiple media resources like <video> and <audio>
<embed>     Used to external application or interactive content (plug-in) in a container. 
<track>     Used to <video> and <audio> text tracks.

<canvas>     Using scripting (usually javascript) drawing graphics on the fly.

<datalist>     Includes list of pre-defined options for input controls.
<keygen>     Used to Define a key-pair generator field (for form element.)
<output>     Result of a calculation.

Removed: Below elements are removed from HTML 5.

<acronym>
    <applet>
    <basefont>
    <big>
    <center>
    <dir>
    <font>
    <frame>
    <frameset>
    <noframes>
    <strike>
    <tt>

Friday 8 June 2012

Basics Concept of SEO

Simply SEO stands for Search Engine Optimization OR Search Engine Optimizer.

There are two parts of SEO:
i) On Page Optimization.
ii) Off Page Optimization.

On Page Optimization: This ensures that website pages are optimized properly so that search engine know that for what purpose pages are created.
 Off Page Optimization: Off page optimization calculates all back links for any website from another website. Because search engine treat backlinks as vote, so backlinks are very important for ranking.

Thursday 7 June 2012

What is Subdomain?

Subdomains are second level of domains or its substiture. If main domain is www.mymaindomain.com, then subdomain can be http://subdomain.mymaindomain.com.

Merits:
1) Cost Saving: If any organization want to buy 100 domains for different subject it will cost (100*perdomain cost). But subdomain cost free. So it will cost 0 for 1-10000 (depending upon provider how many subdomains they provide.) subjects.

2) Since all search engines treat subdomains as different for indexing. Like www.mymaindomain.com AND http://subdomain.mymaindomain.com are two different domains for search engines. So website owner get all the benefits of keyword rich website without registering extra domain and hosting cost.


Wednesday 6 June 2012

Introduction of MySql Cursor

 Mysql supports curosr inside stored programs. This is an embedded SQL. Cursors have  some  properties:

i) Asensitive - Server may or may not make a copy of its result table.

ii) Its read only. It means it can't update.

iii) Nonscrollable: It can traversed only one direction, and rows can't skip.

To be noted: Cursor should must appear before handler declarations and after variable and condition declarations.

Example:


CREATE PROCEDURE myCurDemo()
BEGIN
  DECLARE done INT DEFAULT FALSE;
  DECLARE a CHAR(16);
  DECLARE b, c INT;
  DECLARE mycur1 CURSOR FOR SELECT id,data FROM test.table1;
  DECLARE mycur2 CURSOR FOR SELECT id FROM test.table2;
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

  OPEN mycur1;
  OPEN mycur2;

  read_loop: LOOP
    FETCH mycur1 INTO a, b;
    FETCH mycur2 INTO c;
    IF done THEN
      LEAVE read_loop;
    END IF;
    IF b < c THEN
      INSERT INTO test.table3 VALUES (a,b);
    ELSE
      INSERT INTO test.table3 VALUES (a,c);
    END IF;
  END LOOP;

  CLOSE mycur1;
  CLOSE mycur2;
END;

Tuesday 5 June 2012

URL Rewriting and SEO

What is URL rewriting?

Most dynamic websites uses variables in the URLs to pass values like: http://www.mywebsite.com/myproducts.php?id=1, which is not SEO friendly. But in the sense of SEO this URL can be change to http://www.mywebsite.com/products/7. This can be done by URL rewriting on .htaccess on Apache environement. To achieve this mod_rewrite module should be ON. IIS (Microsoft server) doesn't include this functionality but using add-ons it can be used. ISAPI_Rewrite can be used to mod_rewrite functionality in IIS environment.

1) Simple replacement:

http://www.mywebsite.com/product_details_and_info.php

RewriteEngine On # Turn on the rewriting engine
RewriteRule ^product-details/?$ product_detals_and_info.php [NC,L]

The above code will change URL below:

http://www.mywebsite.com/product-details/

2) Match pattern and replacement:

http://www.mywebsite.com/product_lists.php?pid=10

RewriteRule ^products/([0-9]+)/?$ product_lists.php?pid=$1 [NC,L]

http://www.mywebsite.com/products/10/

Here $1 will replace all number in pid (like pid=10) with pid number after products (like /products/10).

3) Regular Expression match:

Because this pattern match with regular expression(RE) so be careful with special characters of RE.

RewriteRule ^rssfeed.xml$ rssfeed.php [NC,L]

Above example will not only match rssfeed.xml but also will match rssfeed1xml, rssfeed-xml. So to avoid this use below code.

RewriteRule ^rssfeed\.xml$ rssfeed.php [NC,L]

Other escaping character lists are:

     . => Any character
     * => Zero or more of the preceding
     + => One or more of the preceding
     {} => Minimum to maximum quantifier
     ? => Ungreedy modifier
     ! => Negative Pattern OR At start of string
     ^ => Start of string, or negative if at the start of a range
     $ => End of string
     [] => Match any of contents
     - => Range if used between square brackets
     () => Group, backreferenced group
     | => Alternative, OR
     \ => The escape character itself

4) Content Moved

RewriteRule ^articles/?$ http://www.mywebsite.com/articles/ [R,NC,L]

Here R flag denotes that articles is moved temporarily. Either a substitution URL can be given or header will sent back a code 302, it means moved temporarily.

RewriteRule ^article/?$ http://www.new-domain.com/article/ [R=301,NC,L]

Here R=301 shows that content is moved permanentaly.

Other Flags:
     C => Chained with next rule
     CO=cookie => Set specified cookie
     E=var:value => Set environment variable var to value
     F => Forbidden - sends a 403 header to the user
     G => Gone means no longer exists
     H=handler => set handler
     L => Last - stop processing rules
     N => Next - continue processing rules
     NC => Case insensitive
     NE => Do not escape special URL characters in output
     NS => Ignore this rule if the request is a subrequest
     P => Proxy
     PT => Pass through ( when processing URLs with additional handlers, e.g., mod_alias)
     R => Temporary redirect to new URL
     R=301 => Permanent redirect to new URL
     QSA => Append query string from request to substituted URL
     S=x => Skip next x rules
     T=mime-type => Force specified mime type


What is $_SERVER ??

$_SERVER is a superglobal array in PHP. It contains following values:

    $_SERVER['UNIQUE_ID']
    $_SERVER['HTTP_HOST']
    $_SERVER['HTTP_USER_AGENT']
    $_SERVER['HTTP_ACCEPT']
    $_SERVER['HTTP_ACCEPT_LANGUAGE']
    $_SERVER['HTTP_ACCEPT_ENCODING']
    $_SERVER['HTTP_ACCEPT_CHARSET']
    $_SERVER['HTTP_KEEP_ALIVE']
    $_SERVER['HTTP_CONNECTION']
    $_SERVER['HTTP_CACHE_CONTROL']
    $_SERVER['PATH']
    $_SERVER['SERVER_SIGNATURE']
    $_SERVER['SERVER_SOFTWARE']
    $_SERVER['SERVER_NAME']
    $_SERVER['SERVER_ADDR']
    $_SERVER['SERVER_PORT']
    $_SERVER['REMOTE_ADDR']
    $_SERVER['DOCUMENT_ROOT']
    $_SERVER['SERVER_ADMIN']
    $_SERVER['SCRIPT_FILENAME']
    $_SERVER['REMOTE_PORT']
    $_SERVER['GATEWAY_INTERFACE']
    $_SERVER['SERVER_PROTOCOL']
    $_SERVER['REQUEST_METHOD']
    $_SERVER['QUERY_STRING']
    $_SERVER['REQUEST_URI']
    $_SERVER['SCRIPT_NAME']
    $_SERVER['PHP_SELF']
    $_SERVER['REQUEST_TIME']

Sunday 3 June 2012

File Location in LAMP Environment.

1) php.ini
      It depends upon Linux distribution and PHP Version , but some common locations may be:

a) /etc/php.ini
b) /etc/php/php.ini
c) /etc/php5/php.ini
d) /usr/bin/php5/bin/php.ini
 OR

find by command: find / -name php.ini   

Saturday 2 June 2012

Benefits of Stored Procedures.

Advantages of Stored Procedures:

1) Stored porcedures separates database access logic from the application logic.

2) SQL can be pre-compiled which increases the speed of the application.

3) More processing can be done on database server due to stored procedures contain program logic, which reduces bandwidth consumed to sending data back to the application.

4) On the implementation of n-tier application, stored procedures separates the data layer from the server layer.

5) Applications can be grant execute privileges to the stored procedures, while being unable to access the tables directly. It enables security feature of stored procedure.