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;
}