Thursday, December 20, 2012

Sunday, December 09, 2012

Cooking in Aberdeen

As opposed to my home country, here in Aberdeen I do not have the luxury to ride my motorcycle, play the bass guitar, or indulge myself in other outdoor hobbies (although I am planning a skiing session in the next couple of days)...

...Therefore I started a new hobby - that of cooking. Anyways, due to cold, it's always a good excuse to use the oven! This is a common joke here in the neighbourhood. So the following pictures show some of the stuff I have been cooking for the past weeks.

From top to bottom: Egg fried rice with mushrooms, chocolate walnut whiskey cake (unglazed), the same cake glazed, Irish coffee (made with Scotch whiskey!) and extra-large coconut balls.

Other stuff I have been brewing are vanilla cake, banana crusty cake, pork chops with caramelized onions. Ok now I am getting hungry...

Snowy days in Aberdeen

Well Aberdeen is not all roses, and sometimes you gotta spend whole days at home to shelter from snow and rain... But sometimes I do enjoy taking the occasional small stroll in the snow.

No I am not the grim reaper. But there just happened to be a Christmas Crib in the middle. 

Dunnottar Castle in Stonehaven - Aberdeen

Going to Stonehaven to see the Dunnottar Castle was our second cultural visit. (Sorry I did not blog/took pictures of our first cultural visit at the Aberdeen Maritime Museum, although I confess it was a fantastic experience).

It was thanks to our buddy Josef who drove us and joined us in this place, a couple of miles away from the center, towards the shire. I confess I have never seen a castle like this...

As usual, took the first opportunity to try the local beer later on in the day...

Colder days in Aberdeen

Although during the first few days in Aberdeen, the weather was great, the temperature barely touched more than 5 celsius, but I admit that in comparison I did not feel as cold as in Malta due to lower humidity levels. 

On our third week the snow started to appear - a common phenomenon in Scotland - much less in Malta - or should I put it, snow never appeared in Malta (although we commonly overnight frost with 'snow').

Looking at the last two pictures we were surprised in a naive way...I'll explain why in a later post - but let me just say that the snowing in the following days was ten times more intensive!

First few days in Aberdeen

Been in Aberdeen for the last month but I was slacking in keeping up with my blog for technical reasons...So now I will post some chronological posts following this one with my current stay at Aberdeen... I will not blabber a lot... Pictures will talk by themselves.

oh wait ... Just one comment...The first few days here were better than in Malta in terms of weather .

Monday, September 24, 2012

Project Streetfighter ZXR 750 complete!

Today I got the ZXR 750 bike back from the sprayer...yeah I know: too many delays!

It is now a fully fletched streetfighter and feels totally different from how it was - although it is much more comfortable, I have to take some time to actually adjust from more than 6 months riding just an enduro (my beloved XR400) to ride it confidently especially in the notorious Maltese roads.

This is how it was originally when I bought the bike almost two years ago:

Related posts of this project:

Got myself the Note Android 4.0.4

Those who follow my blog know about my bad experience with the drowned iPhone 3GS. For a couple of months I have temporary used an old Nokia E51 which I tethered because of the remote nature of my work. Could not wait anymore so I got a Chinese Android 4.0.4.

The phone arrived today - beautifully boxed like the real deal. The specs, are actually very real!!

  1. CPU: 1GHz
  2. Screen: WVGA high-definition display 5 inch
  3. TV Mobile
  4. Large Battery Capacity: 2500mA
  5. ROM 32GBit + RAM 4GBit
  6. Dual SIM Card
Pretty awesome huh?

Sunday, September 23, 2012

Offroad experience in Gozo with XR400

I spent this weekend with my family in Gozo to take a break from a year of stressful activities. I took the opportunity to go solo with my XR400 to do some trailing and offroading. My favorite locations were Saguna Hills, Ta' Cenc, Imgarr ix-Xwieni, l-Gharb, San Lawrenz and Dwejra.

My XR not only withstood the fields, rocks and all the other plenty of trails, but gave me pleasure and fun in the process. The 4WD is of my bro Eman who was with me through this experience.

As a reminder, if you happen to ride a Honda XR in Malta or you are simply a fan of these fantastic machines, join our Facebook group.

Friday, September 14, 2012

Joining MySQL tables from different schemas

Today I ran into a situation whereby a client needed to join 2 tables which happened to be in different schemas but on the same host. One of the schemas was not being replicated and this particular table was moved appropriately there. To join tables which reside in different schemas, it is very simple:

SELECT u1.*, u2.* FROM database1.users u1 LEFT JOIN database2.users u2 ON WHERE > 10 and < 100

Thursday, September 13, 2012

See timestamp with Linux history command

You can see a recollection of commands on a linux system by using the history command. I would like to share with you a good trick to not only see the command, but also the timestamp it was executed. This is particularly useful for auditing. You simply need to set the environmental variable as follows:


Now, history will display commands as follows:

 1476  2012-09-13 06:25:59 mysql
 1477  2012-09-13 06:25:59 exit
 1478  2012-09-13 06:26:02 history | less

The ultimate Linux screen tip

Ok maybe all my blog titles about Linux screen tool seem exaggerated but I cannot stress enough how this tool boosts my productivity! One of my biggest tips is the follow.

Paste the following code in your $HOME/.screenrc file (create it if it does not exist):

shell -${SHELL}
defscrollback 4096
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
bind ' ' windowlist -b
bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"

To give you an idea, this is what a typical screen session looks to me:

Sometimes I go hardcore mode and insert screens within screen sessions...but more on that in another article..

MySQL dumping triggers and procedures

To dump MySQL triggers and stored procedures using mysqldump, you have two options:

1) Dump the mysql schema (which may not always be feasible)


2) Use the following mysqldump command:

mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql

Insert a line at start of file in Linux

Adding a line at the end of file is very simple in Linux with the '>>' redirector. But adding a line at the beginning of the file entails the use of 'sed'. Suppose we have a file lines.txt:


If we want to add 'aaa' at the beginning we can use the following command:

sed -i '1i aaa' lines.txt

Tuesday, September 11, 2012

Soon moving to Aberdeen

I will be soon moving to Aberdeen for a year. I think this will happen next month and I am really excited. Would be really cool if I met someone who is reading this blog who happens to be a remote IT contractor as well.

Monday, September 10, 2012

People working from home are healthier and wiser

Ever since I embarked the journey of working from home, I have never actually talked about it..But for today let me just direct you to a good article:

Sunday, September 09, 2012

Bye bye macbook!

Today I departed from my beloved macbook which I faithfully used for the past two years. Due to increased workload I had recently upgraded machine (no not another macbook! I went Linux..) so I had no use for it. Good news is that I managed to sell it for the same price I got it.

Saturday, September 08, 2012

Mysqldump - dump insert statements only

If you are only interested in generating the insert statements (i.e. exclude create/drop table, comments, locks, and stuff like that) you may want to use the --compact -t options. I normally use it when I want to do bulk inserts and create a table a priori without indexes.

Friday, September 07, 2012

More Linux Screen tricks

How to detach the screen from within another screen?
Ctrl-a a d

How to rename window?
Ctrl-a A

Saturday, September 01, 2012

Honda XR Malta Club

Last week I opened the Honda XR Malta facebook group ( The feedback was quite successful, maybe in the near future it will take the shape of a club where members can meet and discuss all the things they want about their XR.

If you are a Honda XR owner or just an admirer of these motorcycles here in Malta, you are encouraged to join this group and participate.

Wednesday, August 29, 2012

Blogging from 3G tethered connection on E51

The connection is pretty fast to work on...I will explain how I tethered my E51 in another article! PS: This is not a bullshit post - since I work from home and my internet connection screwed up, I had to resort to 3G!

Monday, August 27, 2012

MySQL Error while dropping tables: Cannot delete or update a parent row: a foreign key constraint fails

If you know what you are doing and you still want to drop a table containing foreign constraints, then you need to follow this procedure:


Perl DBI - Connecting Perl to MySQL database

Knowing how to connect Perl with a database is imperative and very useful. Luckily there is a Perl module called DBI which makes our things easier. In this article I will demonstrate how to write a Perl program to connect to a MySQL database and fetch some rows. Consider the following code:


use strict;
use warnings;
use DBI;

# Main program

# Subroutines
sub main {
  my $dbn="dbi:mysql:testdb:localhost:3306";
  my $dbh=DBI->connect($dbn, "user", "password") or die "Unable to connect: $DBI::errstr\n";
  my $select_query="SELECT * FROM t1 ORDER BY id ASC";
  my $select_h = $dbh->prepare($select_query) or die "Unable to prepare: $DBI::errstr\n";
  $select_h->execute() or die "Unable to execute: $DBI::errstr\n";
  while ( my @data = $select_h->fetchrow_array()) {
    print "Column 1: $data[0], Column 2: $data[1]\n";

1. Before starting make sure you type the use DBI statement.
2. Define the database handle as follows: dbi:mysql:db_name:db_host:db_port:db_user:db_password.
3. Connect to instance using DBI->connect().
4. Prepare statement using $db_handle->prepare().
5. Execute statement using execute().
6. Fetch rows by looping the fetchrow_array() function.
7. Finish the statement and Disconnect from handle.

Sunday, August 26, 2012

Perl parallel tasks using fork

I am working on a Perl application which needs to do repetitive tasks. As such I am using the mighty fork() - actually to make things easier for myself, I am using the Parallel::ForkManager module. The following piece of code spawns 5 children running as parallel processes:


use strict;
use warnings;
use Parallel::ForkManager;


sub main {

  my $pm = new Parallel::ForkManager(5);

  for (my $i=0; $i <= 10; $i++) {
    my $pid = $pm->start and next;
    print "Spawned process $$\n";


Note: The child PID returns 0 inside parent but we can use the $$ special variable to get the PID of the child.

Perl thread vs fork

After an extensive research on parallel processing with Perl I came to the conclusion when to use threads and when to use forks.

1. If you have a set of repetitive tasks, use forks.
2. If you require lots of communication between processes, use threads.

Remember that threads are heavier than forks but on the other hand forks are too complex to handle inter-process communication. Sometimes you may just need to share parent variables to children and if that's enough, than go for forks.

Saturday, August 25, 2012

From gedit to geany

I want to hit myself for not discovering geany earlier. This is a fantastic lightweight IDE/text-editor for Linux. Do yourselves a favor and install it if you haven't done so. For those familiar with Notepad++ on Windows, this is practically similar with more features such as a built-in terminal, support for projects, color picker, etc...

Friday, August 24, 2012

WhatsApp and Nokia Symbian phones

Many Nokia users (including myself) used to hate WhatsApp because it drains the mobile's battery almost after a couple of hours. This was due to a bug which is now fixed. Go ahead and download the latest version from their website.

Thursday, August 23, 2012

This blog got rejected from Adsense 5 times

... and I don't give a fuck anymore ;)

Introduction to pt-table-sync and pt-table-checksum

In this post I would like to introduce you to a couple of must-have tools from Percona which enable you to validate the table contents between two MySQL databases. This is especially useful in replication setups and as a way to ensure that both master and slave have the exact same data, and if not, to sync them accordingly.

pt-table-checksum: This tool can be used to detect any differences between master and slave, however it is not able to tell which are the differences - only where are they.
Usage example: pt-table-checksum -uusername -ppassword --create-replicate-table --replicate percona.checksums -h master1

pt-table-sync: This tool can be used both to detect differences between master and slave and to fix the differences. Unlike pt-table-checksum, this tool is able to actually understand the difference between the master and slave.
Usage example: pt-table-sync -uusername -ppassword --print --sync-to-master --replicate percona.checksums -h slave1 --databases database1, database2

One common question is "why do you normally run pt-table-checksum before pt-table-sync?". The answer is simply so pt-table-sync does less work! In fact, pt-table-checksum will record in a table (percona.checksums) where there are difference (but it doesn't know what are the differences) and pt-table-sync will analyze and correct only these chunks.

For example: If you have a table with 1M rows and you run pt-table-checksum using chunks of 1k rows each, pt-table-checksum detects that in 3 chunks there are differences. When you then run pt-table-sync it will analyze and correct only these 3 chunks (3k rows) instead of the whole table.

Wednesday, August 22, 2012

What sort of music you listen when you work?

I personally like putting my media player in the background streaming classic rock, although at the moment I am listening to the whole Beatles discography. What about you?

Merge multiple Google Calendars

So yesterday I was complaining that my old Nokia E51 was only able to sync one calendar through the Mail for Exchange tool. This is a biggie for me as I have many other shared calendars which I use. Apparently there is no out of the box solution which would allow us to automatically copy events from one calendar to another and keep them sort of in sync.

The current solution to this quite common problem is to export the calendar as ical and then reimport it to the target calendar.

Step 1 - Export to ical:
- In the google calendar list go to the left hand side and from the pull down menu of the source calendar, click on Calendar Settings
- scroll down->Private Address->right click the ICAL button and save it to your desktop

Step 2- Import to your calendar:
- In the google calendar list go to the left hand side and from the pull down menu of the Other Calendars parent menu, click on Import Calendar. Choose the destination calendar and you're ready.

Tuesday, August 21, 2012

Nokia e51 internet connectivity

I connect to internet on my E51 using one of these methods:

1. Wifi - this mobile has one hell of a signal strength, especially if you disable the power saving setting in the Access Point of your wifi profile (settings->connection->access points->your wifi profile->advanced settings). To save some battery, once i connect to the wifi, I switch off the scanning from the front screen.

2. UMTS/3G/HSDPA - this is also known as packet data and which costs you money per MB downloaded/uploaded. I normally disable this when I am connected to wifi (just in case!) by going on settings->connection->packet data->high speed packet access->Disabled.

Display multiple variables in mysql

Sometimes you might need to gather a handful of variables in one statement. This can be done by using the following syntax:

james@ebony ~ $ mysql -uroot -p ebonydb -e "show variables where 
variable_name like 'long_query_time' 
or variable_name like 'read_only'"
| Variable_name   | Value     |
| long_query_time | 10.000000 |
| read_only       | OFF       |

Bye Bye Iphone 3GS, back to Nokia E51

Yesterday's midnight swim was remarkably inaugurated by an accidental iPhone dive which I left in the swimming trunks pocket. Apparently this is a very common fate for these mobile phones.

I had no other option to go back to my old Nokia E51, which thinking about it is a really good phone for work. Did the usual stuff - google sync, whatsapp, etc. Only one thing I was disappointed with - Nokia's "Mail for Exchange", which by the way integrates seamlessly with Google Mail and Google Calendar, supports only one try to work around with that.

Other than that I discovered some features which are quite unique - enable power thresholds for wifi signals being the one which caught my attention.

Anyways, due to its long time in the box, I need a new battery, so I ordered one from flea bay - only after I made sure this could be a suitable phone to work with in at least the next 6 months. My next project is to figure out how to tether it.

Friday, August 03, 2012

Change your Youtube login email

Today I managed to reclaim back my original youtube channel. I had to wait for Youtube monkeys for more than a year to be able to give us the option of changing the login email address. The process is now very simple - go to the bottom of the account settings screen and choose to unlink your google account from the youtube account:

Now you are able to link your account with your new email address.

Thursday, August 02, 2012

Add workspaces in Linux Mint Cinnamon

Although the Cinnamon desktop environment is available to every Linux distro, it is much more widespread and popular among the Linux Mint users. One of the most common questions I get asked is how to add or remove workspaces. We know that by default we get two workspaces, unlike Gnome which sometimes comes with four.

The solution is simple - move the mouse to the top left corner of the screen and you will get to the 'expo' mode, made popular by the mac community:

You can add a new workspace by clicking on the righthand bar (it has the plus sign on it). You can remove existing workspaces but hovering over them and clicking on the top right corner, as shown in the image above. If you hover the mouse again to the top left corner of the screen, you will go back to your desktop. You can hover to the other workspaces by pressing ctrl-alt and the left or right arrow keys.