share some interview advanced level questions related to some Open source : Linux, Apache, Mysql, Php, Java.
Thursday, December 24, 2009
Reliance Broadband+, Tata Photon+ Detects in Ubuntu 9, Detect Plug2surf
Sometime it's become a big problem for Ubuntu user to detect the USB broadband device, in some forums everybody suggest KPP installer or some changes in wv.conf file, this is a big myth follow a simple steps and enjoy...:
Plug in your device to computer:
1. Enable your networking.
2. In networking option choose mobile boradband
3. Click ADD and welcome screen appear
4 click forward choose country then service provider
5. if service provider not in list choose another (Reliance not in list).
6. click on summary and apply change then enter / edit the user name & password
or phone number (if required) then save & connect
7. See in the right side of top panel one image start moving and give u welcome message....enjoy internet it works
Monday, December 21, 2009
What is FEDERATED Engine / how use to it.
what is FEDERATED engine.
The FEDERATED storage engine is available beginning with MySQL 5.0.3. It is a storage engine that accesses data in tables of remote databases rather than in local tables.
How to Use FEDERATED Tables
The procedure for using FEDERATED tables is very simple. Normally, you have two servers running, either both on the same host or on different hosts. (It is possible for aFEDERATED table to use another table that is managed by the same server, although there is little point in doing so.)
First, you must have a table on the remote server that you want to access by using aFEDERATED table. Suppose that the remote table is in the federated database and is defined like this:
CREATE TABLE test_table ( id INT(20) NOT NULL AUTO_INCREMENT, name VARCHAR(32) NOT NULL DEFAULT '', other INT(20) NOT NULL DEFAULT '0', PRIMARY KEY (id), INDEX name (name), INDEX other_key (other) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The example uses a MyISAM table, but the table could use any storage engine.
Next, create a FEDERATED table on the local server for accessing the remote table:
CREATE TABLE federated_table ( id INT(20) NOT NULL AUTO_INCREMENT, name VARCHAR(32) NOT NULL DEFAULT '', other INT(20) NOT NULL DEFAULT '0', PRIMARY KEY (id), INDEX name (name), INDEX other_key (other) ) ENGINE=FEDERATED DEFAULT CHARSET=latin1 CONNECTION='mysql://fed_user@remote_host:9306/federated/test_table';
(Before MySQL 5.0.13, use COMMENT rather than CONNECTION.)
The basic structure of this table should match that of the remote table, except that theENGINE table option should be FEDERATED and the CONNECTION table option is a connection string that indicates to the FEDERATED engine how to connect to the remote server.
Note:
You can improve the performance of a FEDERATED table by adding indexes to the table on the host, even though the tables will not actually be created locally. The optimization will occur because the query sent to the remote server will include the contents of the WHERE clause will be sent to the remote server and executed locally. This reduces the network traffic that would otherwise request the entire table from the server for local processing.
The FEDERATED engine creates only the test_table.frm file in the federateddatabase.
The remote host information indicates the remote server to which your local server connects, and the database and table information indicates which remote table to use as the data source. In this example, the remote server is indicated to be running asremote_host on port 9306, so there must be a MySQL server running on the remote host and listening to port 9306.
Tuesday, November 10, 2009
Using PHP Namespaces
PHP 5.3 introduces a much requested feature for object-oriented programmers: namespaces. At the time of this writing, version 5.3 of PHP was in development, but is planned on being released in the near future.
One of the purposes object-oriented programming is to remove ambiguous development and data access items. This basically means identifying common functionality and creating the most reusable framework possible, typically in the form of classes. When creating this functionality, you will begin to have issues with naming conventions and narrowing down functionality even further. To resolve this scoping issue, namespaces allow you to contain those bits of code even more.
It seems that PHP will be going with a similar namespace setup as C++. In order to declare a namespace, you will use the “namespace” keyword.
-
- namespace MyNamespace;
-
- class Test {
- public function hello() {
- }
- }
- ?>
The declaration above simply states that all elements contained in this script will be referenced with the “MyNamespace” namespace. You will need to place the “namespace” declaration at the top of the script.
In order to use a portion of functionality within this script, we will use the Scope Resolution Operator and instantiate the “Test” class.
-
- // Requiring the namespace file is a good indication that you don’t need to use namespaces, but this is only an example!
- require(‘the_file_above.php’);
- $test = new MyNamespace::Test();
- $test->hello();
- // Prints ‘hello’
- ?>
Monday, October 19, 2009
LAMP - Apache, PHP, MySQL Installation easy steps
Some like it binary some like compiling, I am amongst the compiling ones..
here are some easy steps that I usually follow to compile Apache, PHP to my machine.
- Apache
- ./configure --prefix=/usr/local/apache2.2.6 --enable-so --enable-proxy --enable-rewrite --enable-expires --enable-headers --enable-deflate --enable-ssl
- sudo make
- sudo make install
- cd /usr/local
- ln -s apache2.2.6 apache
- cd
- PHP
- ./configure --prefix=/usr/local/php5.2.5 --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs --with-pdo-mysql --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib
- sudo make
- sudo make install
- cd /usr/local
- ln -s php5.2.5 php
- Configure Apache httpd.conf for PHP module
- LoadModule php5_module modules/libphp5.so
- AddType application/x-httpd-php .php .phtml
Wednesday, October 7, 2009
Advanced Php Questions...
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.
SELECT customerNumber id, contactLastname name FROM customers UNION SELECT employeeNumber id,firstname name FROM employees
Here is the excerpt of the outputid nameIn order to use ORDER BY to sort the result you have to use it after the last SELECTstatement. It would be the best to parenthesize all the SELECT statements and place ORDER BY after the last one. Suppose we use the want to sort the combination of employees and customers in the query above we can do as follows:
------ ---------------
103 Schmitt
112 King
114 Ferguson
119 Labrune
121 Bergulfsen
124 Nelson
125 Piestrzeniewicz
128 Keitel
129 Murphy
131 Lee
(SELECT customerNumber id,contactLastname name FROM customers) UNION (SELECT employeeNumber id,firstname name FROM employees) ORDER BY name,id
First it orders the result set by name and then by id What if we don’t use alias for each column in the SELECT statement? MySQL uses the column names in the first SELECTstatement as the label of the result therefore you can rewrite the query above as follows:(SELECT customerNumber, contactLastname FROM customers) UNION (SELECT employeeNumber, firstname FROM employees) ORDER BY contactLastname, customerNumber
or you can also use the column position in the ORDER BY clause like following query(SELECT customerNumber, contactLastname FROM customers) UNION (SELECT employeeNumber,firstname FROM employees) ORDER BY 2, 1
Thursday, July 9, 2009
Find Duplicate Data
Lets the table name is report and its have a two field, id and type.
type contain a numbers of duplicate records...
first retrieve the all records from table:
select type,id from report;
type | id |
php | 1 |
php | 2 |
mysql | 3 |
mysql | 4 |
lamp | 5 |
lamp | 6 |
use command:
select count(type), id from report group by type having count(type)>1;
get the records like this:
count(type) | id |
2 | 1 |
2 | 2 |
2 | 3 |
the above table explains the id 1,2,3 contain the 2 number of duplicates data.
Thursday, June 18, 2009
Php Interview Question
builder : make and return one object various ways.
factory method: methods to make and return components of one object various ways.
prototype: make a object by the cloning of object which u said as a prototype.
singletone : the class distributes the class of itself.
6. find the difference between two dates
$date1 = "2007-03-24";
$date2 = "2009-06-26";
$diff = abs(strtotime($date2) - strtotime($date1));
//abs absolute value
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
printf("%d years, %d months, %d days\n", $years, $months, $days);
7.What is Exception Handling.
With php 5 came a new object oriented way to dealing with error.
Exception Handling is used to change the normal flow of code execution if a specified
error is occur.
This is what normally happens when an exception is triggered:
- The current code state is saved
- The code execution will switch to a predefined (custom) exception handler function.
- Depending on the situation, the handler may then resume the execution from the saved code state, terminate the script execution or continue the script from a different location in the code.
We will show different error handling methods:
- Basic use of Exceptions
- Creating a custom exception handler
- Multiple exceptions
- Re-throwing an exception
- Setting a top level exception handler
Note: Exceptions should only be used with error conditions, and should not be used to jump to another place in the code at a specified point.
function checkNumber($number){
if($number>1){
throw new Exception ("Value must be 1 or less then 1");
}
return true;
}
try{
checkNumber(2);
print "the try message is display";
}
catch(Exception $number){
echo "Message".$number->getMessage();
}
8.How validate email address except regular expressions.
filter_var($email, FILTER_VALIDATE_EMAIL);
function ($email){
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
print $email. "is not valid email id";
}
else{
print "email valid";
}