Tuesday, December 27, 2011
On a new centos 5 install must things to do first
If you are a engineer working on software development you must run both these commands, this will save you a lot of time later
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
Monday, October 18, 2010
cvs update failed to create lock #cvs.lock
chmod -R 777 <cvs path>/<project directory>
e.g., chmod -R 777 /cvs/myproject
Thursday, August 12, 2010
macro `AM_PATH_CPPUNIT' not found in library
cppunit
cppunit-devel
rerun your program and it should run without any problems.
Friday, May 07, 2010
Catastrophic: event fd doesn't match conn fd!
Compile memcached and use --with-libevent=[ place where libevent is insalled ]
before you start memcached create link in /usr/lib for all the libevent library files.
You are good to go.
Saturday, April 10, 2010
Command to list directories/folders in linux
[root@192.168.1.1]$ ls -l | grep ^d
This lists all the directories under the current directory.
Tuesday, December 15, 2009
How to fix SVCHOST.EXE REGSVR32.EXE Application Error Memory Could not be written / read
SVCHOST.EXE-3530F672.pf
I deleted it and rebooted my system. The error has disappeared.
For all kind of memory related problems for any of windows OS applications like svchost.exe, regsvr32.exe, etc., you can follow this article to resolve it. Say, if you have cleaned your system of Trojans and Viruses, you must also check the prefetch folder under WINDOWS directory for the file names that have similar file names as the application name displayed in error window. If you find any, its recommended to delete these files and reboot the system.
Sunday, June 14, 2009
Installing and Configuring apache flood on CentOS
you can follow these simple steps to install flood on your system
Download flood from
svn co http://svn.apache.org/repos/asf/httpd/flood/trunk flood
or
Browse to http://www.apache.org/dyn/closer.cgi/httpd/flood/ and download from a mirror
If you want to install on remote machine you can also
wget http://apache.mirror.facebook.net//httpd/flood/flood-0.4.tar.gz
untar the compressed file where it is downloaded on your system by issuing the following command
[root@myserver] tar zxf flood-0.4.tar.gz
dowload apr-1, and apr-1-util from http://apr.apache.org/download.cgi
wget http://apache.opensourceresources.org/apr/apr-1.3.5.tar.gz
wget http://apache.opensourceresources.org/apr/apr-util-1.3.7.tar.gz
untar both apr files as it was done for flood
[root@myserver] cd apr-1.3.5
[root@myserver] ./configure
[root@myserver] ./make
[root@myserver] ./make install
and now for apr-1-util
[root@myserver] cd ../apr-util-1.3.7
[root@myserver] ./configure
[root@myserver] ./make
[root@myserver] ./make install
after installing both apr and apr-util flood can be compiled and installed; flood is built on top of these utilities.
[root@myserver] cd ../flood-0.4
[root@myserver] ./configure --with-apr=/usr/local/src/apr-1.3.5/apr-1-config --with-apr-util=/usr/local/src/apr-util-1.3.7/apu-1-config
[root@myserver] ./make
[root@myserver] ./make install
Optionally you may have to get a shell script from http://linux.derkeiler.com/Newsgroups/linux.redhat/2005-03/0373.html if at the time of configuring you get errors like x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized
Happy Flooding!!!
Friday, June 05, 2009
Tuesday, April 14, 2009
Calling static class methods with uasort
class Testuasort
{
static function mysort($a, $b)
{
if ($a[0] == $b[0])
{
if($a[1] == $b[1]) return 0;
return $a[1] > $b[1] ? -1 : 1;
}
return $a[0] < $b[0] ? -1 : 1;
}
static function sortOnfield($narr)
{
uasort($narr, array(self,'mysort'));
return $narr;
}
}
?>
Further reading at http://bugs.php.net/bug.php?id=14104&edit=1
Friday, March 27, 2009
Configure failed for xml/expat , apr-util
On cent-os, redhat, fedora:
yum install expat-devel
yum install apr-devel
On ubuntu, debian
apt-get install libexpat1-dev
apt-get install libapr1-dev
and then configure your application
Friday, December 12, 2008
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
If you happen to encounter this error while installing a perl configured script, it may be possible that your machine doesn't have perl MakeMaker so you need to update perl and its libraries
Installation on Fedora
yum install perl-devel
on Debian/Ubuntu
apt-get install perl-devel
This would install the latest stable version of perl and its dependent libraries. After update run the command
perl Makefile.PL
I everything is all right you may see a message like this
Checking if your kit is complete...
Looks good
Writing Makefile for HTTPD::Bench::ApacheBench
ApacheBench is the package I was installing on my system.
Tuesday, November 18, 2008
Working with CVS
How do I checkout a branch?
cvs [-d /<cvs directory>
This would checkout your files in the folder
How do I checkout a single file from cvs?
cvs
NB: Text within <> symbols have to be replaced with actual names as they exist on your CVS repository.
Monday, May 19, 2008
nawk - where to find it?
ln -s /usr/awk /usr/nawk
configure make and install
Wednesday, April 30, 2008
Compiling ServerLimit in Apache 2.x
Workaround for this is to compile Apache with increased ServerLimit. So, before you compile, open prefork.c that would be at
and find the text "DEFAULT_SERVER_LIMIT" then go to the line that says #define DEFAULT_SERVER_LIMIT
there you would find 256 against this directive, change it to the value that you need your ServerLimit to, I changed it to 1000.
Configure, make and make install, and you are all set
Sunday, September 30, 2007
Interview questions for PHP and MySQL - Part 1
PHP
Q1.Can we write windows like applications in PHP.
Ans : Yes using PHP-GTK on linux and WinBinder on windows.
Q2.What difference does it make when I declare variables with $ and $ in prefix.
Ans: $x = "Lion";
$$x = "Zebra";
echo $Lion;
would display "Zebra"
Use : creating runtime variables
Q3.What is the difference between strpos and stripos function
Ans: strpos is case sensitive search, and stripos is case insensitive search
Q4.What are the ways by which we can find out if a variable has been declared?
Ans: isset or empty language constructs
Q5.What is "global" and how to use it?
Ans: variables declared outside the functions can be used inside the function using global keyword
Q6.What is the difference between echo and print
Ans: echo can take more than one parameter for displaying.
print cannot take more than one
e.g
echo 'This', 'That' //is valid
print 'This', 'That' //is invalid
print returns 1 always.
echo cannot be used to return anything
$ret = print "Abcd" //valid
$ret = echo "Abcd" //invalid
Q7.What are predefined variables in php, give some examples.
Ans: PHP provides an additional set of predefined arrays containing variables from the web server (if applicable), the environment, and user input. These new arrays are rather special in that they are automatically global
[ Resource Link : http://in.php.net/manual/en/language.variables.predefined.php ]
e.g., $_SERVER, $_REQUEST, $_POST, $_GET, $_ENV, $_COOKIE, $_FILES, $_SESSION, $GLOBALS, $php_errormsg, $http_response_header
Q8.Give examples of predefined classes in PHP, and specify the use of anyone of them.
Ans: stdClass, Exception,_PHP_Incomplete_Class, php_user_filter, Directory
Exception : for exception handling
Directory: dir class
Q9.Declaring a class.
Ans: public/private/protected [static] class <classname> extends <baseclassname>{
public $x;
…
public function method_a() {
…
}
}
Q10.How can we instantiate a class with default values.
Ans: Write a function with the same name as class and assign values to the vars.
E.g.:
class myclass {
private $var1, $var2;
function myclass() {
$this->var1 = "Demo";
$this->var2 = "Disabled";
}
function __get($x) {
return $this->$x;
}
}
$m = new myclass();
echo $m->var1 . " Vars " . $m->var2;
Q11.Abstraction, interfaces explain the main difference.
Ans: a) Abstract classes cannot be instantiated,
b) They start with keyword abstract before the class name,
c) One can force the methods to be declared in the inheriting class by creating
abstract functions
d) only abstract class can have abstract methods
eg.
abstract class a {
abstract function b();
public function c() {
echo "Can be used as it is";
}
}
class m extends a {
public function b() {
echo "Defined function b";
}
}
$tClass = new m();
$tClass->b();
$tClass->c();
Q12.Interface classes only provide the skeleton of the class that the inheriting class must implement.
Eg.
interface Person{
public function myFunc();
}
class Employee implements Person {
public function myFunc() {
echo "Implemented";
}
}
$tClass = new Employee();
$tClass->myFunc();
Q13.What are magic methods?
Ans: Functionalities like serializing, converting objects to string, getting setting values without explicit get and set methods for the variables etc, are magic functionality. PHP defines methods with names starting with __(double underscore).
Eg. __get, __set, __construct, __destruct, __set, __isset, __unset, __sleep, __wakeup, __toString, __clone, __autoload, __set_state
[ Resource Link : http://in.php.net/manual/en/language.oop5.magic.php ]
Q14.What does function `eval` do?
Ans: Evaluate a string as PHP code;
Eg. eval('echo "This would be printed"');
Q15.What is the method by which PHP converts datatype of a given variable.
Ans: settype()
$a = "10"; // $a is string
settype($a,"integer"); // $a is integer
Q.Can we change php.ini settings at the runtime, and how?
Ans : Yes, using ini_set();
Q16.What is the difference between sort(), assort() and ksort? Under what circumstances would you use each of these?
Ans: Sorts an array, sorts an array and maintains index association, Sorts an array by key
Simple sort (sorts on values)
Simple sort after sorting the array (lets assume size of array is 10) rearranges the index, if we want to access element at index[5], using a simple sort an element value would have changed, but in assort the value is still held by index 5 though its position in the array may be 10th.
Ksort – sorts the array by key and maintains the key to data correlations
Q17.What is the difference between foo() & @foo()?
Ans: if an error occurs calling foo() would show up the error on the screen, whereas, @foo() would suppress the error because ‘@’ is a error control operator.
Q18.What is the difference between mysql_fetch_row() and mysql_fetch_array() and mysql_fetch_object?
Ans: mysql_fetch_row() – fetches a row as an enumerated array
mysql_fetch_array() - Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_object - Fetch a result row as an object
Q19.What is the difference between include & include_once? include & require?
Ans: include_once includes the script only once if it is already included in the execution of the script
Include includes the script everytime the include is encountered in the code
Require is identical to include except that it results in fatal error when file is not present in the include_path.
Q20.What type of inheritance PHP supports?
Ans: An object can inherit only from one base class. Multiple inheritance is not supported in PHP.
Q21.How can we call an object's method by using the variable functions?
Ans: If MyClass contains function myFunction()
…
$foo = new MyClass();
$var = "myFunction";
$c->$var();
[ Resource Link : http://in.php.net/manual/en/functions.variable-functions.php ]
Ajax, Cross site scripting (JavaScript).
Q22.What is the use of AJAX?
Ans: If a page contains form that needs to be updated constantly based on runtime values, a javascript code constantly sends user input to the system and displays the results from the server, without refreshing the whole page.
Q23.What is cross site scripting, and how to avoid it?
Ans: Injecting a javascript code in the response of a form that is capable of calling and executing scripts from other site.
Occurs when variables holding form values are not cleaned with html code escaping functions.
Clean the variables before storing or before display. Recommendation is to display the code clean and store the value as it is, unless its specified otherwise.
MYSQL.
Q1.What is a join, what types of join are supported in MySQL.
Ans: A ‘join’ joins two table in such a way that all or partial records are selected from both the table based on join criteria.
Joins supported in mysql are :
[INNER | CROSS] JOIN
STRAIGHT_JOIN
LEFT [OUTER] JOIN
NATURAL [LEFT [OUTER]] JOIN
RIGHT [OUTER] JOIN
NATURAL [RIGHT [OUTER]] JOIN
Q2.In MySQL, what table type is required for foreign keys to work?
Ans: innoDB
Q3.How does full text search work.
Ans: A table must be a myISAM table
Table must have char varchar and text columns
FULLTEXT index must be created at the time of creation of table
Q4.What is the use of files .frm, .MYD, .MYI
Ans: frm files store the table definition
MYD files store the data
MYI files store the index
Q5.What is maximum size of a database in MySQL?
Ans: 65+GB / table / [ limited by the OS]
Q6.How many columns can exist in a mySql table?
Ans: 4096 colums
Q7.What is the maximum size of a row in a mysql table?
Ans: 65,535 not including blobs (as these are stored separately)
Q8. What would you use if you have a choice Natural [left] join or inner join or left join with using clause?
Ans: The NATURAL [LEFT] JOIN of two tables is defined to be semantically
equivalent to an INNER JOIN or a LEFT JOIN with a USING clause that names all columns that exist in both tables
[ Resource Link : http://dev.mysql.com/doc/refman/5.1/en/join.html ]
Thursday, June 14, 2007
How to restore data from a previous PostgreSQL installation
1. Check for the version of previous Postgresql installation.
/.../data/PG_VERSION (location of directory data under previous postgresql installation directory)
2. Check if it matches the current version i.e if the version of Postgresql from PG_VERSION file matches your current Postgresql installation
- >If the versions match, just clean start your postgresql using your old directory in the data path
pg_ctl start -D /data path to previous installation/
- > if the versions don't match as it was in my case, [I had Postgresql 7.4 installed previously and now I wanted to get the data on to Postgresql 8.4] we have to do a bit more than just starting database server with old data path.
Steps to recover data from previous version of Postgresql
a) install Postgresql 7.4 (remember even if you cannot find version 7.4 you can install any 7.x version)
for this, I downloaded the source and compiled and installed it on my system
Ubuntu users don't have to go through all this they can directly use binary package download from
https://launchpad.net/ubuntu/+source/postgresql/7.4.5-3
This site also has downloadable source code so people who use Linux flavors for which binary is not available can rebuild the binary on their system locally.
RPM binary packages are also available from www.postgresql.org
http://www.postgresql.org/ftp/binary/v7.4.17/
Once installed, use the command in step-2, Postgresql should mount the database without any errors, login to postgresql database server and you should be able to see all your previous data.
Thursday, December 07, 2006
Making the best use of Internet
Babelfish Translation
The sites that I commonly use. So, welcome to the yet unexplored area of Internet.
Tuesday, November 14, 2006
Setup Alias for your directories on Apache
1. open httpd.conf for editing in your favorite text editor. Please be sure, you edit the right file.
2. search for word "Alias" [without quotes]. After search you may find something like this
# Alias ... [ alias name ] [full path name]
3. Delete # from the line, if present, otherwise add your own Alias directive as below.
Alias /img "C:\Myimages\images"
where "/img" is the alias you want to have for directory "C:\Myimages\images"
4. Save the file
6. Restart apache [ refer http://httpd.apache.org/ for starting up your apache webserver, incase you don't know how to]
Thats it, folks !!
Thursday, October 19, 2006
I wish there were UnDo commands in Life too
Sunday, October 15, 2006
How to crash your hard drive?
Every time I thought of my system, I felt miserable. It all just happened too fast, and by the time I realized it was just a bit too late. Now, when I look back and think about how it all happened, I am convinced; they were series of events that were waiting to be discovered by me. I perhaps may have done something to not let it happen, but I guess I was too excited with the outcome of the adventures I was having with my system. No idea ever flashed, for what was actually in store for me, and what I learnt was something that happened for the first time with me. In spite of being in the field of computers for over a decade, I never encountered this kind of problem. For once it did occur in my mind this was getting more exciting and can be a good feed for a desi techno masala action thriller!
I have a dual boot hard drive with Linux on one and Windows on the other partition. The Linux partition had its swap file on the same partition where OS was installed. Power cuts use to make my Linux OS repair its file system every time I boot on Linux, so I tried to create a swap partition on one of my other partitions, all in good faith. I made a DOS partition, on one of the four partitions I have, and formatted my newly created partition. I left some space for Linux swap. I thought I would do the rest of my work from Linux itself. I started my system and phew.., my GRUB loader failed!. I tried and tried, but couldn’t get the GRUB loader up, I left it as it is and hoped that it would understand and repair all by itself once I come back from my work. After getting back home, I started my system only to be disappointed, my prayers were unheard, and I was still having the same system showing me the dull black and white screen with messages that only geeks with masters in geekology would be able to comprehend. Though the whole day I tried to find a way out of this tricky situation on the internet, but perhaps the explanations were too alien for me to understand it in depth. Over the years in computers I have understood one thing, as you keep learning; the messages get more and more cryptic, something like “GRUB Loader failed Error 17”. Being into application development I am more used to getting meaningful error messages and I get the source code to debug. Here, I had more challenging situation, and tried seeking help from one of my friends, but he was too as clueless as I was. Finally I thought of using some commands on NT Recovery console, I have been reading it all on the internet while I was searching for repairing GRUB. And I thought of trying it, but then, what unfolded was absolutely funny. My system was unusable, NT reported error as if a dutiful mom was looking for her babies … it was not able to find NTLDR and I knew I was doomed. What I did was not easy, I wrote the boot record by using FIXBOOT and though difficult, I could do it with so much ease was because I didn’t know much about its actions on a multi-boot hard drive. I learnt one thing after all this adventure that, I should not use this command next time I am caught in this kind of situation. But perhaps, the adventure with my system was not yet over and script for the other part of my adventure was getting ready in my mind. Last time when I saw list of commands on recovery console of NT, I saw one more command called FIXMBR. I saw a ray of hope in this command as I read earlier on the net that GRUB has to do something with the MBR and this command was looking more promising as the time passed. My desire of seeing my system working was growing stronger every second I spent time in isolation. Even if it meant I cannot use Linux for sometime. I wanted to see my system ‘That Worked’ and, I was ready to take my chances. I ran the command and it gave me a warning message of loosing all the data on the hard drive, I went ahead and pressed