Saturday, April 28, 2012

Installing joomla on ubuntu in 15 minutes

This is a simple and easy to use guide to install joomla without any permission issues on ubuntu. You can successfully install joomla within 15 minutes.

Let's start the clock and start working.

First you need to have a web server on your local machine. Xampp is the most popular open source web server which installs all the required components for your web server.
Download XAMPP for Linux to your your Home folder.

Install XAMPP

Open Terminal and enter:

sudo tar xvfz xampp-linux-1.7.7.tar.gz -C /opt

(replace xampp-linux-1.7.7.tar.gz with the version of XAMPP you downloaded).

This installs ... Apache2, mysql and php5 as well as an ftp server.

Start the xampp server with this command.

sudo /opt/lampp/lampp start

Test your XAMPP localhost server

Open your Browser and point it to
The index.php will redirect to
There you will find instructions on how to change default usernames/passwords. On a PC that does not server files to the Internet or LAN then changing the defaults is personal choice.

Get Joomla

Download the latest Joomla instalation zip [1]

Unzip to your hard drive

Connect to localhost with an FTP client. You can use FileZilla client as an open source ftp client. you can download it from here

once you installed filezilla, start filezilla and connect to your localhost server with following information.

host: localhost

username: nobody

password: lampp

Create a folder for your Joomla on the localhost server

FTP the unpacked Joomla installation files to the newly created Joomla folder. You can drag and drop files using filezilla client.

  • The XAMPP installation sets the correct Ownership of the files and permissions.

  • Using the CHOWN command will cause Ownership problems with xampp.

  • Using nautilus to manipulate folders/files on localhost will cause Ownership problems with xampp.

Configure Joomla

In your Browser type
In the first Joomla installation screen if error reporting is shown as on then:

In your Terminal type

sudo gedit /opt/lampp/etc/php.ini

In the php.ini file, locate

error_reporting =

And change the value to

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Also locate

display_errors = On

And change the value to

display_errors = Off

Stop then restart xampp for the new settings to take effect

FTP layer is NOT needed

Then  go to your phpmyadmin database page and create a database for the joomla installation. You can do this by going to your localhost folder and then click on the phpmyadmin link and then it will take you to the phpmyadmin home page.

create a database named db_joomla (or whatever name you like)

once the database is created, go to the phpmyadmin home page and click on previleges tab and create a new user and asign all the previleges from the option.

username: user_joomla

password: joomla123 (Best practise is to use the generate password option).

OK. Now you have a separate database for your joomla installation.

Database info

Host: localhost

Database name: db_joomla
Database user: user_joomla
Password for Database user: joomla123
Administrator password is your choice.

Installing Sample Data is recommended for the novice user.

After installation delete the installation directory and point your Browser to:
That's it. Now you have installed joomla on your ubuntu machine within 15 minutes.
Cheers !!!!!!!!!!!

Thursday, April 26, 2012

Find File existence in windows in C++

Windows doesn't have a built-in function that checks if a file with a given name exists. It can be trivially written using GetFileAttributes or FindFirstFile APIs. Version below uses GetFileAttributes.

/* Return TRUE if file 'fileName' exists */
bool FileExists(const TCHAR *fileName)
    DWORD       fileAttr;

    fileAttr = GetFileAttributes(fileName);
    if (0xFFFFFFFF == fileAttr)
        return false;
    return true;

Wednesday, April 25, 2012

change mysql port on xampp

 Nice to be back with another solution for a common (not so) problem which google takes some time to find a proper solution. As mentioned in the title of the post, this thing happens when i was installing xampp server on my office computer. After successfully installing the xampp server, i was trying to start the mysql service using the control panel. But when i start the mysql service, it was trying to start but finally it was failing to start on port 3306. It gave some error about port 3306.

After few hours of google search i realized that the root cause for this issue was that port 3306 is using by another mysql service which was installed from another application. Then i had to change the port number to another one to start the mysql service on xampp server.

To change the port successfully, i had to change the port number in following files in the mentioned manner.

You can change the port number to 3308 from 3306 in \xampp\mysql\bin\my.ini file in a couple of places.

There is also a couple of default MySQL port settings in the \xampp\php\php.ini file that would also need changing.

Save the files and restart Apache and MySQL to test.

Cheers !!!!!!!!!

Sunday, April 22, 2012

How to change the root password in Ubuntu

As default Ubuntu has no password set for the root user, To gain root access you have to type in your own user password. This is the password you set for the first user while installing Ubuntu.

To manually set a password for the root user, type in the following in the shell:
sudo passwd

After that you are asked to type in the new root password twice. Finally, your root user has its own password.

Thursday, April 12, 2012

How to pin Eclipse to the ubuntu 11.04 Unity launcher

 If you are developing in ubuntu with eclipse, you may want  to add your eclipse shortcut to the ubuntu unity launcher. But if you open the eclipse, you may see that the eclipse is in the launcher, but the icon is not displaying and only a question mark icon appears. This is a simple solution to add ubuntu icon to the launcher menu. You can use the same procedure to add any other program to your launcher menu.
  1. Go to the ubuntu desktop and right click on it.
  2. Select, "Create Launcher.." option.

        3. Fill the required fields as shown in the below image.

In the command field above, select the eclipse file inside the eclipse folder in your file system.

        4. Select the icon by clicking the icon box in the top left hand corner and go to the eclipse folder in your file system and choose the eclipse icon "eclipse.xpm" and it will be display as below after the correct selection.

        5. Now you can see eclipse icon on the desktop. Double click the icon and start eclipse.
        6. Now the eclipse icon can be seen in your launcher since it is started. Right click the eclipse icon on the launcher and select the option "Keep in Launcher ..".
        7. Exit the eclipse and now you can see that eclipse is displayed in the launcher and the icon is properly displayed

cheers !!!!!!!!!!

Android testing with Monkey tool - a comprehensive guide

If you are in the android scene for some time, you may have heard about this tool. Monkey tool is a simple but very important tool to test android applications for their stability. It is a command-line tool that you can run on any emulator instance or on a device. Basically it sends out random key events and clicks to the device or emulator. If you have done testing on WM devices, you may have used a similar testing tool called hopper. In this tutorial i am hoping to guide you through the basic operations you can do with monkey tool and also some more advance and specific tasks.

The Monkey includes a number of options, but they break down into four primary categories:
  • Basic configuration options - such as setting the number of events to attempt.
  • Operational constraints - such as restricting the test to a single package.
  • Event types and frequencies - such as key events, click events and time interval between events.
  • Debugging options.

When the Monkey runs, it generates events and sends them to the system. It also watches the system under test and looks for three conditions, which it treats specially:

  • If you have constrained the Monkey to run in one or more specific packages, it watches for attempts to navigate to any other packages, and blocks them.
  • If your application crashes or receives any sort of unhandled exception, the Monkey will stop and report the error.
  • If your application generates an application not responding(ANR) error, the Monkey will stop and report the error.

Depending on the verbosity level you have selected, you will also see reports on the progress of the Monkey and the events being generated.

That's enough .... where is the actual test? ....

How to run monkey?

As mentioned above, monkey is a command line tool. In a command line or in a linux terminal window, you can run your first monkey test with the following command.

$>adb shell monkey -v 100

adb - connect to the device
shell - start the terminal (command line) on the device/emulator
monkey - start the monkey tool
-v - verbose mode
100 - number of random events to be sent

You will see some messages displaying on your command line window and if you are fortunate you may experience that monkey tool exits before it completes 100 events due to some exception or ANR scenario. But that will depend on the random events it sends and the applications you have. 

How to run monkey on my own application?

OK.. Now you know how to run monkey and what are things it can do up to some level. Let's run this test entirely on your own application. Let's you have installed the package "" and you want to test this application against random clicks.

$>adb shell monkey -p -v 500

-p - This will specify the application package you need to test. 

How to run the same event sequence again?

Sometimes you may want to check whether a particular failure always happens or randomly happens in an application. In a such scenario, you may need to run the exact same event sequence with monkey tool. You can achieve that goal like this.

Run your first test with

$>adb shell monkey -p -s 999 -v 500

Go back to the same status in the device and run the above command again

$>adb shell monkey -p -s 999 -v 500

-s - This will give the random seed value to generate the random events.

Note: It is essential to start both the tests with the same status in the device. Otherwise It will not give you the same result even though it sends the same events.

This tool has many more features and you can learn about these features from the android developer guide here

Cheers !!!!!!!

Wednesday, April 11, 2012

ජීවිතය සහ දහම


හරයෙන් තොර දැවයෙන් කවර ප්‍රයෝජනද? ගුණයෙන් තොර ඖෂධයෙන් කවර ප්‍රයෝජනද? රසයෙන් හා පෝෂණයෙන් තොර ආහාරය කුමකටද? එමෙන්ම ධර්මයෙන් තොර ජිවිතයෙන් ඇති ඵලය කවරේද?
ධර්මය සැබවින්ම ජීවිතය අලංකාර කරයි. ශක්තිමත් කරයි. වටිනා බවට පමුණුවයි. ධර්මයෙන් වෙන්ව කවර සැපතක්ද? කවර ප්‍රීතියක්ද? ධර්මය නම් ජිවිතයේ හරයයි. ජිවිතයේ ඵලයයි. ධර්මය අමතක කොට, ධර්මය නොසලකා යමෙක් ජිවත් වෙයි නම් ඔහු සැමවිටම වටිනා මනුෂ්‍ය දිවිය නිකරුනේ විනාශ කර ගනියි.
ඔබ කියන වචන, කරන වැඩ, සිතන සිතුවිලි සියල්ලම ධර්මානුකුල විය යුතුය. දිනපතා ඔබගේ ජීවිතය ධර්මයට අනුව ගමන් කරන්නේදැයි සිතා බැලිය යුතුය. එසේ නොවෙයි නම් අද සිටම ධර්මානුකුලව ජීවිතය ගෙන යාමට උත්සාහ කල යුතුය. එසේ නොකළහොත් ඔබගේ ජිවිතයෙන් නියම ප්‍රයෝජනය ඔබට ලබා ගත නොහැකි වනු ඇත.

Tuesday, April 10, 2012

monkeyrunner tutorial - running tests on multiple devices with monkeyrunner

OK.. Great ... Now you know what is monkeyrunner and how to run tests with monkeyrunner. Let's discuss about one important feature of the monkeyrunner tool. Running tests on multiple devices with a single python script.

It looks like a big ask. But that is as simple as drinking a Sri Lankan Tea ...
By following my previous posts

now you are running some scripts with monkeyrunner. Let's add some little bit of information to that script.

#First you need to import the modules which you are using in this script
from import MonkeyRunner, MonkeyDevice

#Then you have to connect to the device which you are running your test
device = MonkeyRunner.waitForConnection()

Wait here !!!!!!

In this script you are waiting for a connection to a running android device or emulator implicitly. Rather than doing like that, you can explicitly tell what emulator or device you may need to connect. You can do that like this.

# Timeout value for waiting for connection 10 seconds
timeout = 10000 

# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection(timeout, "emulator-5554")

here you specify which device you need to connect by the id of the emulator or device.
 If you want to connect to another device within the same script, you can do like this

device2 = MonkeyRunner.waitForConnection(timeout, "emulator-5556")

Then you can do all the operations you have done with device parameter to device2 parameter.
With this kind of scripting, you can run commands on as many devices you have with you. I believe in sample scripts in tutorials. Here is a sample script in action.

# Imports the monkeyrunner modules used by this program
from import MonkeyRunner, MonkeyDevice
# Timeout value for waiting for connection
timeout = 10000

# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection(timeout, "emulator-5554")

# Installs the Android package. Notice that this method returns a boolean, so
# you can test to see if the installation worked.

# sets a variable with the package's internal name
package = ''

# sets a variable with the name of an Activity in the package
activity = '.SimpleIntentPreferenceActivity'

# sets the name of the component to start
runComponent = package + '/' + activity

# Runs the component

# Wait for few seconds

# Presses the Menu button'KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

# Wait for few seconds

#Touch the new status button
device.touch(160, 460, 'DOWN_AND_UP')

# Wait for few seconds

# Connects to the current device, returning a MonkeyDevice object
device2 = MonkeyRunner.waitForConnection(timeout, "emulator-5556")

# Installs the Android package. Notice that this method returns a boolean, so
# you can test to see if the installation worked.

# sets a variable with the package's internal name
package = ''

# sets a variable with the name of an Activity in the package
activity = '.SimpleIntentPreferenceActivity'

# sets the name of the component to start
runComponent = package + '/' + activity

# Runs the component

# Wait for few seconds

# Presses the Menu button'KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

# Wait for few seconds

#Touch the new status button
device2.touch(160, 460, 'DOWN_AND_UP')

# Takes a screenshot
result = device.takeSnapshot()

# Wait for few seconds

# Writes the screenshot to a file

#Touch the first preference
device2.touch(160, 30, 'DOWN_AND_UP')

#Touch the entre button'KEYCODE_DPAD_CENTER', MonkeyDevice.DOWN_AND_UP)

# Takes a screenshot
result2 = device2.takeSnapshot()

# Writes the screenshot to a file

Saturday, April 7, 2012

solution for ubuntu not loading stuck in grub terminal

This has cost me lot of my time and effort to recover from this weird situation. There were some other methods to get rid of this situation. But i had a more unique requirement. That i needed my ubuntu installation restored. Because there were lot of things inside my ubuntu installation which were really important. I hope you are someone like me. You don't need loss your ubuntu installation.

Let's move on. 

I had ubuntu installed inside windows 7 using the wubi installer. One day i have shut down the machine after using with ubuntu and i disconnected my power supply before the system shuts down. Unfortunately , my laptop battery has been removed at that time (for a replacement) and when i disconnect the power supply it was totally without power. Next time when i started the machine and i select the ubuntu from operating system selection menu, it goes to grub terminal..

something like this 


There was a note mentioning that you can see the commands by pressing TAB key. I have tried various methods mentioned in internet and i had lost one of my partitions by doing those things. But finally i found a solution.

When you boot Windows and look in the C:\ubuntu\disks directory you'll notice the root.disk is missing. In some cases, the \ubuntu\disks directory is missing completely or is corrupted.

Running chkdsk
Depending on the problem, Windows may have run an automatic chkdsk or you may need to run it manually. It's not always necessary, but it will never hurt, so the first thing is to run it.
  • Go to My Computer on XP or Computer on Vista/7,
  • right click the drive you installed Ubuntu on e.g. right click on C:,
  • select Properties, select the Tools tab, then under Error-checking click Check now.
  • Select to Automatically fix file system errors or Scan for and attempt recovery of bad sectors 
  • When the drive you installed on is C: the computer will tell you it has to schedule the scan for the next time you start your computer. Reboot to complete. 

Locate recovered files/directories
The first thing to do is to look for the \found.000 folder on the drive in question i.e. C:\found.0000. This is hidden by default and (on my Windows 7 install) I also had to tell Windows not to "Hide protected OS files" just to see it. You may also have to recover from an administrator command prompt on Win7 (see below).

Hit the START key, enter CMD, then look above and right click on CMD.exe and select "Run as

C:\>cd \found.000
 Volume in drive C is OS
 Volume Serial Number is B4B7-99A8

 Directory of C:\found.000

19/07/2011  02:02 PM    15,000,000,000 file0000.chk
               1 File(s)              8 bytes
               0 Dir(s)  222,258,069,504 bytes free

So now you look for your root.disk (or other .disk files) and copy them back to the \ubuntu\disks folder. If the entire \ubuntu\disks folder is missing, you'll likely find a dir0000.chk directory and within that the root.disk, swap.disk and empty \boot\grub folders. Copy this back to \ubuntu renaming the directory todisks.

C:\found.000>move file0000.chk \ubuntu\disks\root.disk
        1 file(s) moved.

or if the whole disks folder is recovered
C:\found.000>move dir0000.chk \ubuntu\disks
        1 dir(s) moved.

If you're missing the root.disk but there is no file of that name, it may have been renamed chk0000.chk. Rename this to root.disk and copy back to \ubuntu\disks.

If the corruption was minor, then likely everything will work fine. If the corruption is major Windows may not even recover the root.disk at all.

I hope this helps you to recover your files. Remember to backup important data on your Wubi install. There's no reason to install important personal files on a root.disk - you can access them easily on the /host partition.

Cheers !!!!!!!!!!!

This site has helped me in solving this issue 

Thursday, April 5, 2012

Method to find a file in a directory with C++

Sometimes you may want to check whether a particular file is in the system programatically. Following is a C++ method you can use in Windows enviornment to search for a particular file.

BOOL FindFile(TCHAR* fileName)
        //Folder to be searched
HANDLE h = FindFirstFile(L"\\Windows\\*.*",&data);
BOOL returnValue = FALSE;
TCHAR*   nPtr = new TCHAR [lstrlen( data.cFileName ) + 1];
for( int i = 0; i < lstrlen( data.cFileName ); i++ )
nPtr[i] = TCHAR( data.cFileName[i] );

nPtr[lstrlen( data.cFileName )] = '\0';
if(_tcscmp(fileName, nPtr)==0)
returnValue == TRUE;
//cout << nPtr << endl;

} while(FindNextFile(h,&data));


return returnValue;

You can call this method inside your main application as mentioned below.


Import native DLL into a C++ program

When you are writing C++ programs, sometimes you may need to use third party dll files in your application. This tutorial is a comprehensive guide to using a native dll within a C++ application. Before we start the coding, let's have a small introduction about dynamic loading.

What is Dynamic Loading?

Normally, when you link to a DLL via a LIB file (for example, the MFC DLLs), the DLL is loaded when your application starts up. This kind of loading is referred to as implicit linking, because the system takes care of the DLL loading for you - all you have to do is link with the LIB file.

Dynamic loading (a.k.a. dynamic linking) means that your application loads a DLL just before you call a function in the DLL. For dynamic loading, you do not use a LIB file. Instead, what you do is call a pair of Win32 API functions (LoadLibrary/GetProcAddress) that load the DLL and then retrieve the address of a function in the DLL. Because you explicitly invoke these APIs, this kind of loading is also referred to as explicit linking. To summarize:

  • implicit linking - DLL is loaded automatically when your app starts
  • explicit linking - you write code to load DLL

following acronyms are used in the programming world for these two types of linking.

static linking - static loading, static linking, implicit linking, implicit loading, automatic loading

dynamic linking - dynamic loading, explicit linking, explicit loading, manual loading

Why Use Dynamic Loading?

Before I get into the details of dynamically loading DLLs, let me first answer the question: When is it desirable to dynamically load a DLL? Here are the typical scenarios:

  • You don't have a lib file to link with - this is a pretty lame reason, since if you worked at it you could generate a LIB file. On the whole, though, generating a LIB file is probably more work than just using LoadLibrary/GetProcAddress to dynamically load a DLL.

  • A DLL may not always be present - if you want to provide for some graceful program degradation, you must dynamically load any DLL that may or may not be present on the target machine (example: UXTHEME.DLL, which exists only on XP). If you used implicit linking, your application would never have the chance to degrade gracefully - the system simply would not allow your app to start, and would instead display some alarming message to your user.

  • You need to support multiple feature sets - this is one of the historically valid reasons for using dynamic loading. If you have a product that supports many different features, and you want to load only those features that the customer has paid for, then what you do is package each feature set in its own DLL, and ship the DLL to the customer when he orders it. This is also a very convenient way to add new features (read: plug-ins) to your product, essentially making it open-ended.

  • You need to support multiple platforms - this is also one of the historically valid reasons for using dynamic loading. You need to support multiple platforms (Win98, Win2000, WinXP) and each platform requires slightly different code for some reason. A simple solution is to segregate the code for each platform in its own DLL.

  • You need to speed up the time it takes to load your application - this is another historical reason for using dynamic loading. You will start thinking about this when customers start complaining about how slow your app is to load. The idea is to identify what DLLs are necessary to display the core UI, and then dynamically load all the other DLLs that your app needs.

How to implement with in the code?

Let's start the actual coding. Let's say you have a dll file which is named as mylibrary.dll. You have so many methods inside that library. You need to use the method Start(BOOL id) within your application.

Define a constant name for your dll file. (This is optional)
#define MY_LIBRARY_NAME TEXT("mylibrary.dll")

Declare a Handle for the library file instance.
HINSTANCE g_hinstLibrary;

Define a function pointer to the method you are willing to call from the dll. Signature of the definition should be equal as the actual method.

typedef BOOL (__stdcall *LPFN_START)(BOOL);

Declare a variable of the defined function pointer type
LPFN_START g_sStart;

Load the library file into the instance variable
g_hinstLibrary = ::LoadLibrary(MY_LIBRARY_NAME);

Get the Process address of the specific method you are going to use in your application

if (NULL != g_hinstLibrary)
//Get API addresses
g_sStart = (LPFN_START )GetProcAddress((HMODULE)g_hinstLibrary, TEXT("Start"));

Now you can call the Start(BOOL id) function within your applications main method (or any other method) as below.

if(NULL != g_sStart)

Once you are finished using the function, Release the loaded library

if (NULL != g_hinstLibrary)

This blog has helped me to write this post and some of the sections are copied from there.

Cheers !!!!!!!!!!!!!

Monday, April 2, 2012

Flower, Thunder and You

  • Be soft as a flower when it comes to kindness but 

tough as thunder when it comes to principle.

  • Be courteous and polite at all times but 

never be pushed around

  • Ensure that you are always treated with respect

Sunday, April 1, 2012

ඉනි මගේ ඉහලට

කුල භේදය යන වදන අපගේ දෙසවනට වැටෙන විට අපට සිහි වන්නේ පැරණි ඉන්දීය සමාජය හෝ අතීත සිංහල රජ කාලයයි. එසේ නමුදු මේ කුල භේදය සමාජය තුල සැමදා පවතින බවට ඕනෑ තරම සාක්ෂි තිබේ. වත්මනෙහි එය දුප්පත්, පහල මධ්‍යම, ඉහල මධ්‍යම සහ සුපිරි පැලැන්තිය ලෙස අපට දල වශයෙන් හඳුනා ගත හැක. දුප්පතා උත්සාහ කරන්නේ තමන්ට ඉහලින් ඇති ස්ථරයකට නැගීමටය. අනෙකුත් ස්තර තුල සිටින මිනිසුන්ද එසේමය. (මේ කියන්නේ බහුතරය ගැනය. ). එසේ නමුදු මේ සමාජ ස්තර හරහා ඉහලට නගින මිනිසුන් කිසිම විටෙක තමා ලබන ජයග්‍රහණයන් ගෙන් සැහීමකට පත් වන්නේ නැත. ඔවුන් බොහෝ දෙනෙකුට සතුටු වීමට වෙලාවක් නැත. මන්ද ඔවුන් සැම විටම ඉනි මගේ ඉහලට නගිමින් සිටින නිසාය. එසේ නමුදු තමන්ට ලැබෙන දෙයින් සතුටින් ජිවත්වන ඉතා සුළු පිරිසක්ද මේ සමාජයේ සිටිති. ඔවුන් ඉනි මගේ ඉහලට යාම වෙනුවට තමන්ගේ සතුට සොයා යති. ඔවුන්ට පිනක් දහමක් කිරීමට, සතුටු වීමට, විනෝද චාරිකා යාමට කාලය ඕනේ තරම් තිබේ. එසේ නම් අප උත්සාහ කල යුත්තේ ඉනි මගේ ඉහලට නැගීමට පමණක්ද? අප යම් මොහොතක ඉනි මගේ නැවතී අප ලද ජයග්‍රහණයන්ගෙන් සතුටු විය යුතුය. මුදල් පසු පසම හඹා යාම මගින් අපට කිසි දිනෙක සතුට ලඟා කර ගත නොහැක. ඉනි මගේ ඉහලට නගින අතර මදක් නැවතී ඔබගේ සතුට ගැන දෙවරක් සිතන්න.