Thursday, November 24, 2011

List all indexes in an Oracle tablespace

Sometimes Oracle DBAs need to do some tablespace cleaning and moving indexes from one tablespace to another. If you have hundreds of indexes this may become an awkward task to do manually. This article describes how to use SQL to list all indexes in a given tablespace so that you can automate the object movement.

The view 'dba_indexes' contains useful information about indexes including which tablespaces they belong to. To produce a list of indexes in any given tablespace, one can use the below code:

SELECT * FROM dba_indexes WHERE owner='USER' AND tablespace_name = 'USERS'

You can then feed this list to another script which will do index administration tasks such as rebuild, movement or drop.

Choose the Database Index: Selectivity and Cardinality

It is a known fact that most of the database performance tuning is achieved by building a suitable index. In most database engines, such as Oracle and MySQL, the most popular indexes types are either B*Tree or Bitmap. This article describes how to choose the appropriate index.

Determining the right index is all about cardinality and selectivity.

What is cardinality? Cardinality is the number of distinct values you have in a field. For example if  you have a table with a field Country, there are around 250 possible countries. Thus the cardinality of the Country field is 250.

What is selectivity? Selectivity is what we actually need to gauge the type of index to use. Selectivity can be determined by the following formula:

Selectivity =             Cardinality
                      --------------------
                      Total number of Rows



Taking the previous case, if I have 2500 customers, the selectivity is 250/2500 = 0.1%.

Selectivity is important because it helps us to determine whether to use a Balanced Tree (B*Tree) Index versus a Bitmap index. In general you have to follow these golden rules:

If Selectivity > 4%, use B*Tree index
If Selectivity < 4%, use Bitmap index

In Oracle one can do an audit of the currently used indexes and determine whether they are good or not by using the following query:


SELECT
  INDEX_NAME "NAME",
  DISTINCT_KEYS / NUM_ROWS * 100 "SELECTIVITY %",
  NUM_ROWS,
  DISTINCT_KEYS "DISTINCT",
  LEAF_BLOCKS,
  CLUSTERING_FACTOR,
  BLEVEL "LEVEL",
  AVG_LEAF_BLOCKS_PER_KEY "ALFBPKEY"
FROM
  DBA_INDEXES
WHERE
  DISTINCT_KEYS / NUM_ROWS < .1  AND
  NUM_ROWS > 0
ORDER BY "SELECTIVITY %" DESC;



This will list all indexes which have a selectivity lower than 0.1%. These indexes should be Bitmap, otherwise they are not used by the Cost Based Optimizer.

To determine the selectivity of  a particular index, one can use the following query:

SELECT
  INDEX_NAME "NAME",
  DISTINCT_KEYS / NUM_ROWS * 100 "SELECTIVITY %",
  NUM_ROWS,
  DISTINCT_KEYS "DISTINCT",
  LEAF_BLOCKS,
  CLUSTERING_FACTOR,
  BLEVEL "LEVEL",
  AVG_LEAF_BLOCKS_PER_KEY "ALFBPKEY"
FROM
  DBA_INDEXES
WHERE
 index_name = 'INX_TRAN_FT_EXT_DATE'
ORDER BY "SELECTIVITY %" DESC;



One might argue that the Selectivity model above holds only if there are duplicates within the user record set. Of course it is true for small tables - infact in small tables with low cardinality, one might not even use indexes at all. However one can also use the Birthday Paradox to further predict if there are going to be duplicates.

The Birthday Paradox states that for every 23 persons, a pair will share the same birthday, or written mathematically, there is a 99% probability that there is a duplicate if the following is satisfied:


N = 3.0 * sqrt (cardinality)



, where N is the position within the table which returns the first duplicate. For the example above, for a cardinality of 203, you are 99% certain that you will encounter a duplicate on 3.0 * sqrt (203) = 43rd record.This means that even in a table of 100 rows you will most likely have a duplicate even if the country set is 250!

Saturday, November 12, 2011

Happy Birthday - 6 years old!

This blog, one of the first ones in the Maltese islands, computes its 6th year today. One can browse through old blogposts in the archives menu on the right - me for one enjoyed reading a couple of posts! As they say, time really flies and I try to capture those interesting moments on this blog...

Wednesday, November 09, 2011

Create Oracle Backups in Enterprise Manager

If your Oracle database is connected to the Oracle Grid you can easily manage your backups through Enterprise Manager. This allows you to schedule a multitude of backups without going through complex RMAN scripts.

The following screenshots will guide you through the process of scheduling a backup in Enterprise Manager:

Step 1: Click on the Availability tab and select Backup Settings to define your backup policy:

Step 2:  Choose a suitable backup location:

Step 3: Choose your backup retention policy:

Step 4: Go back to the first screen (Availability tab) and this time click on schedule backup. In this screen choose what you want to backup:

Step 5: In this last screen you choose whether you want a full or an incremental backup.

In the next screens you set a date and a time and finally save your backup.

Monday, November 07, 2011

Windows Batch Script to Delete Old Files

Few of us know that Windows has some not-so-known tools which mimick Unix's powerful commands. Often we require to delete old files on a Windows machine to provide a means of backup retention policy. You don't need to install Perl or other text manipulation languages - Windows got tools of its own!

You can use a tool called FORFILES (download from Microsoft FTP server if you don't have it!) to select a file or set of files and execute a command on each of them. This allows us to filter files by name, timestamp, size and other attributes, and then perform a command based on their result.

The following are some common examples to use FORFILES to delete or display files older than N days:

Print a warning if the testfile is 3 days old or older:
C:\> forfiles /m testfile.txt /c "cmd /c echo file is too old" /d -3
 
Delete the testfile if it is is 3 days old or older:
C:\> forfiles /m testfile.txt /c "cmd /c Del testfile.txt " /d -3
 
Find .xls file that were last modified 60 days ago or older
C:\> FORFILES /M *.xls /C "cmd /c echo @path was changed 60 days ago" /D -60
 
List the size of all .doc files:
C:\> FORFILES /S /M *.doc /C "cmd /c echo @fsize"

Friday, November 04, 2011

Automating Windows SCP scripts with WinSCP

Legacy FTP usage is being phased out and most of you will have to face newer company security policies to start using SCP to transfer your daily backups from one server to another. Luckily for the system administrators, this is easily done using WinSCP's command line console as this article will demonstrate.

The example code below connects to 'example.com' with account 'user' and password 'pass123', uploads a file and closes the session. For the sake of this article, let's call this example.ini:

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
open user:pass123@example.com
 
# Force binary mode transfer
option transfer binary
# Upload file to the local directory d:\
put examplefile.txt d:\
# Disconnect
close


You can then call this script through WinSCP console as follows:

winscp.exe /console /script=example.ini

Thursday, November 03, 2011

Copy and Skip Existing Files in Windows

If you are hardcore old school Batch coders like me, you most probably have stumbled across the requirement to copy your backups from one place to another while skipping files which already exist on the destination point. This article describes a Windows tool which does that very easily.

This tool is called Robocopy and is freely available to all windows users inside the Windows Resource Kit Tools. You can get it from here. Robocopy has many options which we will not discuss in this article, but its default behaviour allows us to copy files and skipping existing ones:

robocopy C:\source\*.bak D:\destination\

Best FREE Firewalls for Windows

Most of the Windows users prefer having a different firewall solution other than the builtin Windows Firewall. This has its advantages and luckily for us there are really great firewalls free of charge!

As of the writing of this article, the best free firewalls for Windows are:

Comodo - Best product in the free-firewall category with impressive performance and an easy-to-use interface
Zone Alarm - Extremely easy to use
Ashampoo - Good free firewall, but not as reliable as our #1 and #2 picks
Agnitum - Recommended by website visitors
Sunbelt/Kerio - The Sunbelt Kerio Personal Firewall will keep on working after the first 30 days, only in a more limited mode, but free

Wednesday, November 02, 2011

Granting privileges on ALL tables in Postgresql

If you have a database and you would like to grant select on all tables to a particular user or role, in Postgresql one must follow an unorthodox procedure. This is described in the following article.

Most users mistakenly believe that to give a privilege on all tables to a user/role, they have to grant the privelege at a database level like so:

grant all on database my_db to developers

This will not work because it will not cascade at a table level. Therefore the correct procedure to grant a privilege on all tables is in following these two steps:

1) Generate grant statements as follows:

select 'grant all on '||schemaname||'.'||tablename||' to developers;' from pg_tables where schemaname in ('my_db', 'public') order by schemaname, tablename;

2) Copy and paste the generated output and run the resulting scripts.

This will grant all privileges on all tables to a particular user or role.

Integrating Postgresql with LDAP + PAM

Integrating Postgresql with LDAP and PAM is very easy as this article will show. The only requirements are that you have already setup LDAP and PAM on your UNIX box.

Create a PAM configuration file for Postgresql, such as /etc/pam.d/postgresql90:

#%PAM-1.0
auth           required        pam_stack.so service=system-auth
account        required        pam_stack.so service=system-auth
session        required        pam_stack.so service=system-auth


Edit pg_hba.conf and add the following line, including the subnet of the client:

# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD
host    all             all             10.255.0.0/24         pam   pamservice=postgresql90



The pamservice method must reflect the name of the PAM configuration file for postgresql created earlier.

Finally edit postgresql.conf and set the 'listen_addresses' to the ip address of the postgresql server. One final last step to affect the changes is to reload the postgres configuration file like this:


pg_ctl reload

Restore Oracle RMAN backup on a new Windows machine

Sometimes disaster strucks (ex. virus, disk failures, etc..) and the only option to get up and running is to restore our Oracle backup onto a new Windows server. This article simplifies the whole process of completely restoring and recovering a database on a brand new Windows server.

1) It is important that we maintain the same directory structure as the original server when restoring Oracle through RMAN. Gather information about your directory structure from your previous (failed) machine:
  • Datafile Location
  • Archivelog Location
  • Oracle Binaries Location
  • RMAN Backups Location
2) Install Oracle software with the same Oracle version as the original server.

3) Place the RMAN backups in the appropriate location as defined in the controlfile.

4) Create Windows service for the database:

C:\>oradim -new  -sid ORCL -startmode m
C:\>oradim -edit -sid ORCL -startmode a

Make sure that the service is started so we may be able to connect to it in the next steps.

5) Get the DBID of the database - I normally get it from the backup report - although this steps is not really necessary (since we restore the SPFILE first) I do recommend it.

6) Create bdump,udump,cdump and create folder at $ORACLE_HOME (if using Oracle versions before 11g)

7) Connect with rman to the target database at local server:

C:\>Documents and Settings\Administrator>set ORACLE_SID=ORCL
C:\>Documents and Settings\Administrator>rman target /


8) Configure RMAN:

RMAN> set dbid 123456789
RMAN> startup nomount


9) Restore SPFILE:

RMAN> restore spfile from 'D:\EXPORT\RMAN\C-3648252040';

10) Startup database:

RMAN> startup force nomount;

11) Restore controlfile:

RMAN> restore controlfile from 'D:\EXPORT\RMAN\C-3648252040';
RMAN> shutdown;
RMAN> exit;

12) Proceed to restore and recovery:

RMAN> startup mount;
RMAN> shutdown immediate;
RMAN> startup mount;
 
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open resetlogs;
RMAN> exit

Now you should have a completely recovered database!

Thursday, September 22, 2011

Delete Duplicate rows from Oracle table

Duplicate data is not a rare incident - infact it's very easy to end up with duplicate data when you do daily database loads and lack constraint keys. This article shows you how to remove these duplicates.

The solution relies on the following two principles:
  1. Identical rows with different rowid's
  2. joining the table by itself
The SQL code to remove duplicates from any table is the following:

delete from
    T1 A
WHERE
    a.rowid >
ANY (
     SELECT
        B.rowid
     FROM
        T1 B
     WHERE
        A.c1 = B.c1 and
        A.c2 = B.c2 and
        A.c3 = B.c3
        )

So how does the script work? The columns c1-c3 identify the composite keys of the row which will make it a unique entry in the table. Thus the subquery will join the table with itself and returns identical rows with a different rowid from the parent query. The delete statement will remove the row with the larger rowid, i.e. the duplicate.

Monday, September 05, 2011

Hide login link in Wordpress

Most Wordpress based websites are not community based and either do not need user feedback or simply do not require user registration. Unfortunately Wordpress still exposes the 'login' link at the banner of the page often confusing the users. This article shows a little hack to hide the login link.

Browse the FTP server which hosts the wordpress installation and open the following file:

<root directory>/wp-includes/general-template.php

Now locate the following function:

function wp_loginout($redirect = '', $echo = true) {
    if ( ! is_user_logged_in() )
        $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
    else
        $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
 
    if ( $echo )
        echo apply_filters('loginout', $link);
    else
        return apply_filters('loginout', $link);
}

and replace it with the following code:

function wp_loginout($redirect = '', $echo = true) {
    if ( ! is_user_logged_in() )
        $link = ''; //'<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
    else
        $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
 
    if ( $echo )
        echo apply_filters('loginout', $link);
    else
        return apply_filters('loginout', $link);
}

This will hide your login link!

Friday, September 02, 2011

Remove the Blogger Header Banner

Blogger is one of the most powerful blogging engines around which is not only free but contains practically no advertisements thus making your blog very personal. The only caveat is the 'Blogger Banner' which is located at the very top of the blog. Most people do not like the banner and normally try to find ways to remove it - although this goes against Blogger's terms and conditions...This article is for educational purposes only.

Go to the Blogger Dashboard and from the Design menu choose Edit HTML:

In the HTML form locate the following code:

/* Variable definitions
  ====================
   <Variable name="mainBgColor" description="Main Background Color"
             type="color" default="#fff" value="#ffffff">
   <Variable name="mainTextColor" description="Text Color" 
type="color" default="#333" value="#333333">
...


All you need to do to remove the Blogger banner is to paste the following CSS code just before the code locate above:

#navbar-iframe {
   display: none !important;
}

Friday, August 05, 2011

Reset 'Next Value' of an Oracle sequence

In all RDBMS's, the power of sequences is just priceless. This is also true for Oracle...Sometime we happen to need to reset the next value of a sequence and unfortunately there is no single line command to do it in Oracle. This article show the basic steps to reset the next or current values of an Oracle sequence.

Let's say that we have a sequence 'my_sequence' (pretty original huh?) whose nextval is 900000:

select my_sequence.nextval from dual;

> 900000

However we discover that after deleting some data from a table, we realize that we need to reset the sequence so that the next value is 400000. This can be done in 3 steps:
  1. Increment the sequence by a negative number which is the difference between the current value and the new value (900001 - 400000)
  2. Get the next value from dual
  3. Re-adjust the increment of the sequence back to 1.

In SQL this can be done as follows:

alter sequence my_sequence increment by -500001;
select my_sequence.nextval from dual;
alter sequence my_sequence increment by 1;

Tuesday, August 02, 2011

SQL UPDATE with JOIN statements in Oracle

You are reading this article as you probably have not found an easy way to UPDATE tables which are in a JOIN statement, in an Oracle database. The problem's solution may sound trivial, until you try it out yourself!

Without going through the erroneous ways to try to update joined tables, let me tell you that the only way you can reliably achieve this in Oracle is by using PL/SQL. The reason is that Oracle needs to know beforehand the joined dataset which is to be updated. Thus this needs to be stored in a cursor, and then updated accordingly.

The following piece of PL/SQL code depicts two tables - 'target' and 'source'. We need to update 'target' rows which are found in 'source' by the corresponding value in 'source'.

DECLARE
   commit_interval number := 1;
   l_count number := 0;    
CURSOR c1 is
    SELECT   
        s.col1 s_col1,
        s.col2 s_col2,
        s.col3 s_col3
    FROM
        target t,
        source s
    WHERE
        t.col1 = s.col1 and
        t.col2 = s.col2 and
        t.col3 = s.col3;
BEGIN
    FOR r IN c1 LOOP
       UPDATE target t
          SET t.col1 = r.s_col1
        WHERE
                t.col2 = r.s_col2 and
                t.col3 = r.s_col3;
      l_count := l_count + 1;
      IF (l_count >= commit_interval) THEN
        COMMIT;
        l_count := 0;
      END IF;
   END LOOP
 COMMIT;
END;
It is important to include all columns in the cursor which are referenced by the WHERE clause in the UPDATE statement.

Tuesday, July 26, 2011

Tuning NFS Performance

Tuning NFS might make you think of 'Need for Speed' - but we all know we are referring to Network File System - one of those love it or hate it network protocols. NFS can be a cheap way to implement shared storage or as the base protocol for a Network Access Storage (NAS) - unfortunately NFS can be slow out of the box, so this article will help you boost a bit of performance from it!

Ok this is not going to be one of those long articles depicting what each mount option of NFS does and what not, without giving an actual solution to tune its performance. In any case, you can use the man page of nfs to check those out! So the most important options which help in speeding up NFS are:

  • udp - contrary to what other people say, we suggest to use udp instead of tcp - this will increase transfer speeds by hundred times without any compromise!
  • wsize/rsize - put these as high as possible, normally values of 32768 or 524288 or 1048576 - just experiment!

Yep it's just as simple as that...no dark secrets. Now you have a fast NFS communication. Thus, in all, the mount options should look something like this:

rw, intr, hard, nolock, wsize=1048576,rsize=1048576, 
udp, nfsvers=3, noauto

Friday, July 22, 2011

Move, Backup or Clone a VirtualBox

Virtualbox is a virtualisation technology owned by Oracle which allows you to install virtual machines on top of your operating system. If you like to setup a test lab or maybe try a new Linux/Windows distro, Virtualbox is a great choice. This article explains how to move, backup or clone a VirtualBox.

Most people run important setups on VirtualBoxes and one may need to move them across other servers, or directories, or maybe take backups to a DVD. Unfortunately this is not trivial as copying the virtualdisk and pasting it to the desired location. In VirtualBox, moving a virtual machine involves these two steps:

  1. Clone the virtual disks (*.vdi)
  2. Create a new virtual machine and add the cloned disks
Cloning a virtual disk can be performed by using the following code:

VBoxManage clonevdi machine-A/boot.vdi 
/media/cdrom/backups/machine-A/boot.vdi

In windows, the code is slightly modified as follows (make sure you enclose the path in double quotes):

VBoxManage clonevdi "c:\machine A\boot.vdi" 
"E:\media\cdrom\backups\machine A\boot.vdi"
Finally create a new virtual machine but use the previously created cloned disk.

Saturday, June 11, 2011

Risis at the Rock the Fest Malta

Maltese rock band Risis are to participate at the Rock the Fest battle of the bands inside the Hard Rock Cafe` St. Julians. Join the fun and vote! If they are among the winners, they will participate at the Farson's Beer Festival this summer...

This will happen on the 23rd June 2011 at around 9pm, and after Ira Losco will be performing as the main guest. More info at their official facebook page - http://www.facebook.com/RisisMusic



Friday, June 03, 2011

Rush concert (Timemachine tour)

Last week I went to London with my friend to see Rush at the O2 arena for their Timemachine tour. It was awesome and look forward to see them again in the future. Our hotel was located in Euston, walking distance from Camden. Since pictures speak louder then words, I leave this blog post with some photos:






A period of transition

At the moment I am transitioning between one job and another - this means I have more time for myself...more time to read, study, play the bass, riding the motorcycle, going to the beach, and of course blogging. I love the summer transitions...

Divorce Referendum

As the entire world or at least Europe knows, last week Malta held a referendum on the legislation for the introduction of divorce. I intentionally did not blog about this for the past months, despite the heavy media and continuous bombardments from peers.

To cut the story short, the outcome was a YES to divorce - although it is not official yet from the parliarment, that would of course leave Philippines as the only country in the world without a legal divorce.

Without taking a stand in favour or against divorce, my next question clearly would be this: Would the Maltese people who fervently voted in favor of divorce still consider to be married by the Church institution?

I will leave the interpretation for that answer to you.

Risis - upcoming Maltese rock band

While being immersed in a busy life, I almost forgot to blog about one of the most important elements to which I dedicate my life - my rock band, Risis. Instead of ranting about it, I will just copy/paste the biography which I had drafted a couple of weeks ago:

Risis are a Maltese rock band formed in 2008. The band was born from a myriad of different names and line-ups, however it all started with drummer Chris Galea who met ex-guitarist of So Chronic and ex Stone Joker, Stefan Farrugia. They auditioned for a number of bassists until they met James Attard whom they knew through his former band White Crimson. Together they covered powerful bands like Muse, Skunk Anansie and Rage Against the Machine until they decided to start working on original material. While looking for a singer, James stumbled across Jodi's profile on Facebook. After a successful audition, Jodi joined Risis and provided the strong voice they were looking for.

The name 'Risis' derives from their former "identity cRisis" syndrome where they used to change their band name before every gig.

All the four members show amazing technical and musical skills, with their songs being personal and powerful as can be felt in their live performances. Risis are currently producing their first single with renowned producer Niki Gravino.

Being a bassist and the appointed PR, as my band mates dubbed, is a juggle between my other elements in life! Yet I cannot complain as it is a very rewarding venture. More info on our facebook page: www.facebook.com/RisisMusic.

Thursday, June 02, 2011

6 Simple Rules for Productivty

Stumbled across some rules which I will try to follow in the upcoming days to boost my productivity!


1) Check your email twice a day MAX (good luck with this one)
2) Check stats only twice a day.
3) Work on ONLY 1 thing at a time.
4) Close all open Windows (including AIM, Skype, Gmail, etc) except the specific project you are working on.
5) Write a to-do list in the morning which you follow.
6) Spend your time working on the thing that will potentially give you the most benefit (profit, rewards, etc)

Saturday, April 16, 2011

Fixing Blogger Upload Image Internal Error

As of the writing of this article, I discovered that most of the Blogger users have been plagued by the notorious "This image could not be uploaded due to an internal error" which of course does not allow bloggers to upload images to their blog. Unfortunately we have also not seen a solution to this problem, so we spent a couple of hours figuring out one...

After some research we discovered the following two things:

  1. Blogger started using Picasa Web Albums to host the uploaded images - your Google account is tied with Picasa
  2. This problem seems to be predominantly present in Google managed domains - so if you have mydomain.com and it is being managed by Google Accounts, then you're more likely to stumble across this problem.

I guess that by now most of you are already suspecting something and are probably trying to log on Picasa web albums (http://picasaweb.google.com/) with your google account - you will get an error that the Picasa service is not available on your domain!

Infact it turns out that the problem started when Google accounts were merged at around July and most services were disabled. This is turn, broke the Blogger functionality to utilise Picasa to host the uploaded images.

Therefore to be able to use Picasa with your Google Account, you must enable it by going through your domain dashboard and follow these screenshots:

Now go to Blogger again and you should be able to upload photos!

Friday, April 15, 2011

DoFollow vs NoFollow hyperlinks

According to the HTML protocol, there are two types of hyperlinks - these are the dofollow and the nofollow links, as have become popularised in the SEO world. Apart from their technical difference, it is good to know why they were invented in the first place, and most importantly, how to locate them.

Dofollow hyperlinks are basically the default (normal) hyperlinks which do not have the nofollow tag. Therefore if a website does not use the nofollow tag, you can treat the link as dofollow.

A normal dofollow link looks like this:

<a href="http://www.r00tb0x.com">r00tb0x.com</a>

whereas a nofollow link looks like this:

<a href="http://www.r00tb0x.com" rel="nofollow">r00tb0x.com</a>

As discussed in a previous article about backlinks, search engines rank pages according to the number of links pointed at them. In the beginning all links were dofollow and spammers started abusing this technique by placing links pointed to their websites on blogs with unmoderated comments, thus increasing their page rank. As a countermeasure against spammers, the nofollow tag was invented to indicate an unapproved link - this tells the search engine to disregard the link and therefore not contribute in the page rank. Nowadays, most blog software marks comments as nofollow (irrelevant of moderated or not).

You may have already figured out, but to tell if a site is dofollow or nofollow, you can look at the source of the page and search for those tags.

The day I got my first superbike

...Was some day last week, and my smile was from ear to ear. Fell immediately in love with a 1994 Kawasaki ZXR 750 superbike racer and got it at a very good price! The poor bike (which was coined as the 'lean mean middle aged green machine' by a friend of mine) was garaged for the last 5 years...I took care of that - 200km in just two days. I also upgraded brake pads to Ferodo as the old ones were all oily!

Pictures speak louder than words, so here is the happy me:



I found a way how to dine at great Maltese restaurants at 50% discounts!

I think you might find this personal rant a bit interesting...So read on!

I like eating a lot...and so does my fiancee`. And we like to choose those nice romantic expensive restaurants...So every week we end up forking tens of euros to satisfy our palate at these restaurants! And keeping up this 'vice' together with the ever increasing cost of living was becoming a bit difficult.

That's until I discovered the now famous Gusto card (www.gusto.com.mt) which allowed both me and a guest to get a 50% discount on every restaurant which is listed on their website...and they got literally more than 100! I think I discovered it a bit late cos it has been existent for a while, but I am sure most of you have never heard of it..

If you haven't already purchased the Gusto card, do so now! But wait...one last important thing...I can share with you a special promo code which you can use while you enter your details at the Gusto site, to get a EUR 5 discount on your card! Yep that's right..more discount :p

The promo code is: 1866

Just enter that code when you purchase the card from www.gusto.com.mt.


Wednesday, March 30, 2011

Create sunburst effect in Gimp

In this article I am going to show you how to create the famous sunburst effect using Gimp. This effect is popularised by party and event posters and can be used as a great background. The concepts explained here can be also used in Photoshop.

This is the end result after reading this article:

Let's start with a blank white image:

Make sure that you set black (or the sunburst color of your choice) as the background color:

Next we are going to use the Blinds filter to fill the image with black vertical lines - Go to Filters...Distorts...Blinds and set the orientation to Vertical, Displacement to 62 and Number of Segments to 12:

The last step is to use the Polar Coordinate filter - Go to Filters...Distorts...Polar Coordinates and leave everything default:

Sunday, February 27, 2011

How to list contents of a .tar.gz without unzip

This one should be included in the UNIX system administration FAQ as it is very handy and a common request...More than often we end up with a filled up disk or partition but while deciding whether deleting that massive zip file we forget its real content. Of course, unarchiving it is impossible due to lack of space, and to make things worse FTP and SCP are disabled! A nightmare...But worry not - there is an easy way to inspect the content of a zip, gzip, tar, or bzip archives in Unix.

# To show content of a tar file
tar -tvf foo.tar
# To show content of a gzip file
tar -ztvf foo.tar.gz
# To show content of a bzip file
tar -jtvf foo.tar.bz

Saturday, February 26, 2011

Sharing one single database across multiple Drupal installations

More often than not, Drupal users get confident and enthusiastic and start creating more than one Drupal website. But there is one big problem - their hosting service only provides one database! Instead of paying more bucks for another database, there is another way to use multiple Drupal installations on the same database...

The solution to this problem is by using a technique called 'Prefixing' whereby you prefix all the table names for that Drupal installation. In other words if you have multiple website, you can share their tables within the same database by naming them as follows:

site1_drupal_table1
site1_drupal_table2
site1_drupal_table3
...
site2_drupal_table1
site2_drupal_table2
site2_drupal_table3


The prefix can be set for each Drupal site installation by editing the file 'settings.php' and setting the $db_prefix template. So for the above example you can set the prefix for site1, but adding this line in settings.php:

$db_prefix = 'site1_';



What happens is that once you run the Drupal installation wizard for site1, all the newly created tables will have the 'site1_' prefix appended to them. This will make tables from different Drupal installations to co-exist within the same database!

Note that you can use the same trick for existing sites which have already been installed. The difference is that you need to manually rename each existing table (ex. through scripts).

Monday, February 14, 2011

Nice sunday ride!

Fitted new GPR exhaust on my CBF 500, and tested it this morning with my brothers! Awesome rumbling sound!! teheheh..

Thursday, January 27, 2011

Find the number of backlinks to any website

Every SEO expert can tell you that one of the most important factors in the ranking of a website is the number of backlinks it has. But the exact process to determine the number of backlinks seems to slip within the cracks. How exactly can you find the number of backlinks of any website/webpage, such as for example that of your competitor?

Although many would argue that the method described here would not be as accurate as method 'xyz', it is currently by far the most reliable method to find backlinks not only in the website you control but also every other website.

The process is simple - using google, you need to enter the following search query:

"website_name" -site:website_name

So for example to determine the number of backlinks of r00tb0x.com, you would enter the following query:

Another r00tb0x article hitting the jackpot

This article has been SEO'd successfully :)

.... first page among 65 million+ other results.

Monday, January 24, 2011

Download Youtube and Flash videos in Safari (OSX)

If you use Safari Internet browser on your OSX box, you can easily and freely download flash videos such as Youtube. Not only that, but you can also use Safari as an HTTP analyzer to help you debug HTTP problems.

Once you are inside the page serving the flash video, press 'Command-Option-A' to enter the Activity Resource. In this window you can see all the downloaded files when you accessed a given page, including downloaded flash videos stored in your browser's cache:

In the above session we have located the file matching the flash video by looking at its size (6.6MB) - in addition to that you can notice that this video stream was still downloading at the time of the screenshot! The file can be downloaded by double clicking the entry.

You can also notice all the other files which constitute the youtube page we were accessing. This is very useful to debug, hack or analyze HTTP traffic.

Wednesday, January 19, 2011

GTD: Getting Things Done with Gmail!

Getting Things Done (GTD) is a method of organising tasks in a stress-free way while boosting the productivity at the same time. There are a lot of commercial software which can be used to adopt this method but one can use Gmail for free! After adopting the GTD approach through Gmail, my productivity increased dramatically!

While explaining the GTD methodology is not within the scope of this article, for starters, this model looks at tasks in a different way than the traditional time management philosophy. GTD is based on making it easy to store, track and retrieve all information related to the things that need to be done, hence the name.

In GTD, each new task has to be immediately categorised as follows:

Action - execute task today
Waiting - awaiting a status from someone before continuing
Deferred - execute task some other day
This model can be easily transported to Gmail by making use of labels:

Each email in the inbox can be considered as a task, and as in GTD, immediately labelled as per above and archived. You can also create a new task by sending an email to yourself:

You will eventually end up with a set of categorised tasks in GTD format as follows:

When you complete the task you can either delete the email or remove the corresponding label. At the end you have nothing but an empty inbox and a set of GTD labelled archived emails representing tasks. You might ask what can we do with emails which are not tasks, such as for example chain emails, jokes, videos or other amusements? Well, we suggest you to read them and archive them, or else give them another label (ex. *others) and check them out later.

But remember that you must make sure to archive ALL emails so that the inbox looks nice and empty at any point in time!

Monday, January 17, 2011

Home doorway pullup bar

I recently invested in a doorway pullup bar which costed me EUR9 from Lidl. Quite a bargain. At the moment I am doing 5 pullups in a row - my target - 10 pullups in a row by end of February!


Sunday, January 09, 2011

Tom Sawyer - Rush Bass cover

This is the first of a series of Rush songs which I'll be covering as a warmup before I go see them live next May 2011 :)



Apologies for all the mistakes but it has been a long time since my last bass cover on youtube so got all eggs-ited.

Thursday, January 06, 2011

How I gained 35 pounds in 1 year...

I know the title looks a bit cheesy, reminiscent of some spammy weight gainer/weight loss/viagra product marketing article...But I am not going to promote any products in this article - just some health and fitness tips from a newbie person who used to be a skinny, rockstar hippy to a 'normal' built individual who enjoys a healthier lifestyle...

So about 12 months ago, I looked like this:

Weighing a mere 125 pounds with no particular healthy lifestyle other than the occasional soccer match with work colleagues. No matter how hard I tried gaining weight by eating bigger portions or trying the occasional weight training, I always failed miserably, ending giving up to all sorts of training.

However one fine day I stumbled across an interesting article which revealed the secret to gain weight for us people who find it extremely hard to gain a pound or two!! The secret lies within these three paradigms:

EATING WELL - TRAINING WELL - SLEEPING WELL




Eating well: Eating like a pig..eating for pleasure..and most of all, think nothing other than eating! In scientific terms, you need to eat 20g of protein every 3 hours for 4 times (i.e. in a span of 12 hours you need to consume around 80g of protein everyday).

Sleeping well: Don't sleep less than 8 hours a day!

Training well: Go to a gym and lift the heaviest weights you can to increase muscle weight. Don't do any cardio and don't lift light weights - just raw heavy weights till you feel your body breaking.

By following these 'laws' I managed to gain 35 pounds in about one year. Apart from that I feel much much stronger and I am taking weight training as a hobby which allows me to vent off much of the stress I accumulate during the day. Check out some pics I recently took and see the difference. Of course this is just the beginning and by no way feel like a bodybuilder - however it is just enough for me to keep myself motivated in this quest. 














Most importantly I hope that these little words motivate young people who shared my same experience!

Monday, January 03, 2011

What do I remember of last year?

If I had to look back at last year and think for a moment, these are probably the things I remember (in no particular order):

  • Got engaged with Petramay
  • Started the wedding plans
  • Bought a terraced house
  • Left my old workplace
  • Started a new job
  • Working with shifts for the first time
  • Went for a cruise for the first time
  • Made new friends
  • Left old friends
  • Named the band to UNDER3KINGDOMS
  • Founded r00tb0x.com and Costansin 
  • Became the motorcycle club's (Raw Bikers) secretary
  • Managed to successfully gain 15kg
  • Started weight training