Saturday, 20 April 2013

Changing mysql username and password used by phpmyadmin

So, I had to do this the other day and I got a bit confused. After poking around a bit, I finally found it. If you have xampp installed, go to the install directory. In my case, this directory is C:\xampp which is the default directory. Locate the phpmyadmin folder and open it. Locate the config.inc.php file within the phpmyadmin folder. Open up the file. You need to make change in the following two lines:

$cfg['Servers'][$i]['user'] = 'root'; 
$cfg['Servers'][$i]['password'] = 'password'

The underlined parts are the ones that you've got to change. This file contains a lot of admin stuff so make sure you look around a bit and understand what it does.

If you don't know what you are doing, ensure you take a backup of the file before changing things.

Sunday, 14 April 2013

How to prevent class redefinition errors in C++

I have just started learning C++ and have been getting a lot of these errors. I finally found a solution to this after spending some time on the internet.

Say for instance you have a class called "Animal" and g++ complains that this class is being redefined. Just add the following two lines at the very top of the Animal.h file:
#ifndef ANIMAL_H
#define ANIMAL_H


and add the following at the very bottom of the file:
#endif

So, if your class is called SomeClass, then it will be SOMECLASS_H instead of ANIMAL_H. You should have these in every header file. It prevents that header file from being redefined more than once.

Saturday, 13 April 2013

How to tell which Linux partition a directory is on?

This is really simple. First of all, you need to know the full path to that directory. "cd" into that directory and type:
pwd

and it will display full path of the directory you are in. Remember that or even better, copy it to the clipboard. Type the following command to know the name of the partition:
df

where replace with the full path of your directory. This in my case becomes "df /data/android/sample".

If you are already in the directory, you can type "df ." and it will give details about the partition you are currently on.

The output should be something like:

Filesystem    1024-blocks      Free %Used    Iused %Iused Mounted on
 /dev/hd4            32768     16016   52%     2271    14% /


The highlighted part is the name of your partition.