zaterdag 19 november 2011

Drupal development, a more pleasant way.

Why this post

In my spare time I am making a website for a youth movement using Drupal. Drupal is a very nice CMS that is quite powerful. You can use a lot of code (modules) that are provided by the Drupal community but if it goes wrong it might be hard to find out why. In the beginning I was just making my changes in the Drupal files and when I wanted to test them I uploaded the files to my hosting provider. It seems that it is hard to find a worse way of Drupal development :-). This week I noticed one of the major disadvantages of my approach. After uploading some code my site reported a 500 error message (server error). Since I don't have access to the server itself I couldn't check if it was indeed the server that was erroneous or that it was something I have done. The next day I still got the same error so it was likely that my code was at fault. Finding the fault was quite hard because the only hint I got was (500 server error). Then I realised that it was my own fault. If you want to do some development you should always invest some time in setting up a proper development environment. I knew this when I started the website project but I was too lazy to do it. Know I found out that is was plain stupid since it is very easy to setup a nice Drupal development!

How to quickly setup a good Drupal development environment.

Thanks to some Drupal enthousiasts setting up a Drupal development is easier than ever. There is a Drupal Quickstart project that provides a virtual machine that contains an Ubuntu OS that is configured for some serious Drupal development. You can find the project at Just follow the steps explained on that website to set up the environment.

The Ubuntu OS contains a Drupal 6 and a Drupal 7 example and also has some nice scripts to setup new Drupal installations. Unfortunately I already had started development and I didn't want to lose my previous work.

Importing an existing Drupal project in you development environment

I had my Drupal files on a USB stick so I could easily import them into the Virtual Machine. I also had a backup of the Drupal tables from my database that I made using phpmyadmin (It is wise to use a prefix like 'Drupal_' or a separate database when performing a Drupal installation).

Setting up the database

In the Virtual Machine (Quickstart) you launch firefox. In the toolbar there will be a link to PHPMyAdmin. You browse to PHPMyAdmin and login using the root as username and quickstart as password. Without selecting a database you click on SQL on the left pane.

This will give you a window where you can enter MySQL statements. Make a user that has the same name as you used when making your Drupal installation and give him the same password.


After typing this statement you click 'Go'. Next you'll have to make the table that you used when making your Drupal installation.


Now you'll have to make sure that your user has the appropriate rights on your table. Because this is a development environment it won't hurt to grant him all rights.


Logout of PHPMyAdmin and log back in using YOUR_USERNAME and YOUR_PASSWORD_IN_PLAIN_TEXT. Now select the table of your Drupal Install which is still empty. Now you can click on import tab on the right pane. There you can select your SQL backup file (click browse) and confirm it (click go). Now your Drupal tables will be imported. I had my files gzipped and I got a strange error. Trying the unzipped SQL-file worked for me. Congratulations your database is setup!

Placing the Drupal files.

For consistency I thought it would be best to place the Drupal files in the websites folder which is located in the home folder of the Quickstart user. Just make a new dir that identifies your drupal installation (e.g. drupal_42) and place the files of your Drupal project there. See to it that you also copy the .htacces file. Files starting with a dot are hidden in Linux. You can make them visible in nautilus by pressing ctrl+h or by using the menu: View-> Show hidden files.

Making it work

All the contents of your Drupal project are in place but how can you view your website? For this you need to do some additional setup. Notice that in the websites folder (/home/quickstart/websites) there is a config folder. This folder contains (links to) all the necessary configuration files that you'll need. Will split the changes per file.


Here you can set aliases that point to IP-addresses. As your localhost (your Virtual machine) will generate your site you will need to setup the name (URL) of your website to point to your localhost. This can be done by adding a rule at the end of the file. You can see that there are already URLs pointing to the localhost, these are the example Drupal installations that are pre-installed. Just add a rule with a URL you like.

Then save your file and close it.


Next you'll have to configure Apache. Apache is the server which will generate the HTML using the PHP files. Your site needs to be registered to Apache so it knows that is should process the necessary files. The configuration files of Apache can be found by following apache-sites-available link in /home/quickstart/websites/config. There you see the config files of the other pre-installed Drupal sites. As I wanted to get my installation working without too much trouble, I made a copy of named Then I changed the content to reflect my project. It is rather straightforward. Just change into And where you see a path pointing to the folder, you change it to the folder where you copied your Drupal project files. Save your changes and all the configuration is done. It might be necessary to restart Apache to notice the configurationfiles.

sudo /etc/init.d/apache2 restart

The result

To view the result open up firefox and browse to your URL (e.g. And you should see your website. If you get a permission denied error you should check the permissions of your files from your drupal installation. The owner should be quickstart and the group should be www-data. (browse to root folder using a command shell and execute sudo chown -R quickstart:www-data . , including the dot!). If it still doesn't work make sure group permissions are set correctly (they should be able to read and execute files). sudo chmod -R 755 *

It works, now what?

Now you have got a server which you can configure yourself. The default is actually good already for development. Warnings and errors are shown in the browser so you can get more debug information than on a production server. There are also IDEs installed on the Virtual machine. Eclipse and Netbeans. I have setup Netbeans but you can use Eclipse also.


Launch netbeans from your desktop or from the upper gnome panel. Click File->New Project... Then in the new window select PHP project with existing sources. Click Next. Then you can select your source folder using the browse button and give the project an appropriate name. You can also select a PHP version that you want to use. Click next again and look at the run configuration. Make sure that the project URL is correct. This is the URL where you browse to see your website in your development environment. The default is http://localhost/ so you probably have to change this to When you click finish your project will be imported into the IDE.

Why should you use an IDE for development? There are multiple reasons actually. You have good syntax highlighting. You have tools for Version control that are integrated into the IDE. You can do real debugging (Setting breakpoints, stepping through code, examining content of variables,...). If you don't know Netbeans or Eclipse it might be interesting to learn how to work with one of them. They are both pretty nice. There are sometimes plugins which configure the IDE for you for Drupal development. I think Eclipse can generate code for Drupal hooks. (Yes it does and for netbeans Don't you love open source community software :-).

And what was the error?

I had a typo in the code for my own custom module. After my function there was one } too much. Again, plain stupid.

vrijdag 4 november 2011

Android Recover Mail password

It's probably necessary that your device is rooted in order to be able to do this. I'm not sure though. This blog post is for people willing to recover there OWN password, do not misuse this information.


Before you can start, it is necessary that the tools of the Android SDK are installed and ready to be used. How to install these tools is explained here

The story

We want to recover the password of our e-mail account. Because android needs this password to download your e-mail, it will store the password on your phone. The data of applications is stored in /data/data. At that location there are directories for the different applications. The directory for mail is There we have to find the password. The password is located in 1 of the databases that is in the folder. The databases are SQLite databases, so the easiest way to recover the password is by browsing the databases using an appropriate tool.

The recovery steps

First you need to get the contents of (You don't need it all but this way you can inspect the other contents also.) This is done by executing the following command in the shell of your ubuntu installation:

adb pull /data/data/ ~/email_of_phone

This will place the contents in a folder named "email_of_phone" in your home directory.

Next you'll need to install a tool to explore the databasefiles. I have used SQLitebrowser which is in the repositories. Just install it by using the command:

sudo apt-get install sqlitebrowser

When this is done you'll have to launch the SQLitebrowser. Just use shell:


The people who are no shell-enthousiasts can be happy, from now on everything is by GUI. The GUI is very straightforward. Click the Folder icon (with the arrow). This opens up a dialog window where you can select your database. The database will be 1 of the databases in ~/email_of_phone/databases. For me it was the EmailProvider.db so you should try that one first :-).

When the databases is opened you can see that there is a table called HostAuth. This might be interesting to find out our authentication credentials. So we click the + sign to the left of it.

Then we can see that it has indeed a password field!

But we are not interested in the table layout. We want the content of the table. So click the "Browse Data" tab.

The last step is changing the table that is shown to HostAuth.

Finally you can read the content of the table. In the Password field, you can read the password in plaintext.

zaterdag 12 maart 2011

Quiet down a Noisy Fan (Sony VAIO VPCEB1S1E model PCG-71211M) (OS independent)

This post will tell you how to solve a noisy fan problem. My notebook ran hot very quickly resulting in a fan that is going crazy. (This post won't be about ubuntu nor android but the solution worked so well that I thought I should share it anyway.)

First it is interesting to think about any possible reasons your PC is running hot. If you are doing very intensive tasks it might be normal that it's hot. But if your notebook or PC runs hot when doing normal stuff (e.g. searching in a large PDF document) then there might be a problem with the heath conduction within your notebook.

My Notebook worked fine before so I knew it wasn't a design flaw of my notebook itself. One very likely possibility is that there is dust in your computer which prevents a good internal air (and thus heat) flow. Since my warranty expired 2 weeks before being fed up with the noise there was only 1 budget friendly solution, so I searched for my screwdrivers.

Before opening up a notebook it can be wise to search for a service/repair manual of your notebook which describes how to open up your notebook. As I couldn't find any on my model (PCG-71211M) I decided to work without a map. Be warned that notebooks can be quite a pain to put together again (ordinary PC's are like 4 piece jigsaw puzzles compared to notebooks!). Luckily my Vaio didn't need a lot of disassembling for my goal.

Now I will describe how I opened up my notebook with some accompanying pictures (you can click on them to enlarge them). If you try this yourself, know that it is on your own responsibility! Lets start with a picture:

This is the backside of your notebook, you might already familiar with it. You can notice that there are quite a lot of screws. Since they may vary in size it is important to work neatly. HINT: It can be useful to work on a large table and put the screw upside down on the table in the same layout you took them out of your notebook. (This sounds lame but if you've got more than 20 screws you won't remember which one went where.)

Ok, first remove the battery. Slide the lock and pull the release button away and you can roll out the battery. Your notebook should look now like the picture below. As you can see there already 19 screws visible (don't worry we only need to remove 21 screws in total).

When you remove screws 16 and 17 you can remove the cover protecting your hard disk. You can raise the cover at the side that is nearest to you (nearest to the bottom of the picture). Then you can see screws 21 and 22. Apparently I forgot number 20 when photo shopping the pictures and I am to lazy to redo them :-).

Now that all the screws are located remove them all! And I mean all of them. Otherwise you can force the body at the places where it is still screwed together! When all screws are gone you can first remove your Hard Disk. When screws 16,17,21 & 22 are removed you can slide your Hard Drive as depicted below. You want to treat this hard disk with care since it contains all your precious data.

After removing your Hard disk you can remove your CD/DVD drive. When screws 6 and 9 are removed, you can just slide it out.

You can also remove the cover that is fixed by screw number 10. Behind this is your RAM memory. I removed the RAM memory also but I don't think it is necessary. (The cover must be removed however!)

Now you should be ready to open up the body! Maybe to be sure you can do a last check to see if all screws are removed. Then you can start lifting the side that is nearest to you and open up the body like it was a treasure chest (full of dust). Be careful however, there are little plastic hooks that hold the body together. So you might have to apply some light pressure at some points using a screw driver. Be gently however since you don't want to break of any of the hooks. It is not hard but the first time you might have to get used to it. When your notebook is opened up it should look like this:

At this moment you might be a bit disappointed as you might have thought that there would be much more dust. But don't worry! The picture above was taken before the cleanup of my notebook so it didn't look too bad either! But the cleaning helped a lot! Before you start cleaning: REMOVE THE POWER SUPPLY OF THE FAN!. This is circled in blue on the picture above.

Now the cleaning can begin. I cleaned it using a vacuum cleaner which can blow air. If you don't have a vacuum cleaner which can blow you might want to search for cans containing pressurized air (so called air dusters). I've heard that sucking air isn't a good idea (don't know if this is true but I'd rather play safe). The metal on the upper part (see picture) I have cleaned using a cloth (that was a bit wet). Then I dried the cloth and cleaned it again. Make sure everything is dry when you put your notebook back together! The other parts I have blown out using the vacuum cleaner. When cleaning the ventilator you should hold it still using one of your hands. Be sure to send a strong air flow through the ventilator shaft. (The metal block that goes to the side of your notebook on the right.) Since this is a place were dust can easily get trapped. (Again hold the ventilator).

When the cleaning is done you can put your notebook back together by performing the steps above in reverse order. THE FIRST STEP IS TO RECONNECT YOUR FAN. If you don't reconnect your fan you are blessed with a notebook that will be very silent (but silence can (and will) kill!). The re-closing of the body is the hardest part. First make sure the back sides (sides furthest away from you) fit together and than close the body. Then gently press the body together at the sides. You might hear little clicking sounds.

Next insert the hard drive and CD/DVD drive again. Just gently slide them back in. Remember that screws 16 and 17 are there to keep the cap fixed to the body so they should be screwed after placing the cover over the hard disk.

If everything is back at its place then you should boot up your notebook and enjoy the silence.

donderdag 24 februari 2011

Ubuntu and EasySMS (for android)


When you are on your computer almost all the time it might be interesting to send sms messages using your computer. There is an application for Android that lets you do this. It is called EasySMS and is available in the Android market.

But it only gets useful if it's configured well. So I want to share my configuration. Important to note is that my configuration is for USB connections. As I prefer a USB connection to a WiFi connection.

Configuration on the phone

After installing the application from the market you can launch the application (you can choose free or paid version. The paid version obviously has some advantages and I bought it).
When the application is launched you see a screen were you can set configuration options. Check the box before "Auto" underneath "Control of services Wifi/USB". Secondly you should set a port for Wifi/USB (mine is set to 2511 but you can choose any number higher than 1023). I have got the HTC Hero and my phone needs the checkbox before "Alt. send" to be checked. Normally you only have to check this if you notice that your messages don't get send.
You can set other configurations as you wish.

Configuration of Ubuntu

This part will tell you how to make it possible to send SMS messages by just clicking one button. A requirement for your system is that you have the Android SDK somewhere on it. You can find the SDK on

First make an simple script "" with the following contents:
$PATH_TO_ANDROID_SDK/tools/adb forward tcp:1977 tcp:2511
google-chrome http://localhost:1977/

Of course you can use another browser by changing google-chrome to firefox or any other browser launching command. $PATH_TO_ANDROID_SDK must be changed to the android SDK folder containing the tools folder. It is important that the bold port numbers match and that the number in italics is the same as the port number that was chosen during the configuration of the phone. Finally you should make the script executable (chmod +x or using the properties window of the file)

Normally you can add a custom application launcher to one of your gnome panels. When creating this launcher you can select an icon and a command. The command is just the path to your script.

This might work for you but I had to do a little bit of extra work. Since my phone wasn't always connected with the right permissions I had to create some udev rules to make sure my phone was accessible. The udev rules should only be executed when you're phone is connected. One way to do this is to find out the VendorId corresponding with your phone. This can be done by executing lsusb WHEN YOUR PHONE IS CONNECTED VIA USB! it will give output of the different USB devices. Find the line corresponding to your phone. Normally every line has a description. Ee.g. I have a htc (=High Tech Corporation) Hero phone and output is:

Bus 002 Device 003: ID 0bb4:0c99 High Tech Computer Corp.

The number after ID and before the following colon will be the vendorid. Now we have got all the information to make the udev rules. Make a file /etc/udev/rules.d/50-android.rules with the following content:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", RUN+="$PATH_TO_ANDROID_SDK/tools/adb start-server"

Finally execute sudo restart udev to make sure the rules are activated. After reconnecting your phone you should be able to use your SMS button!

EasySMS link