Get selected text of an web page including textarea,input box and anchor tag

The JavaScript code below fetches the value anywhere in a page including textarea, input and text fields of the forms.

function GetSelectedText()
{
  var selectedText=(
        window.getSelection
        ?
            window.getSelection()
        :
            document.getSelection
            ?
                document.getSelection()
            :
                document.selection.createRange().text
     );
 if(!selectedText || selectedText=="")
 {
    if(document.activeElement.selectionStart)
    {
     selectedText = document.activeElement.value.substring(
          document.activeElement.selectionStart
          . document.activeElement.selectionEnd);
    }
 }
 return selectedText;
}

The Above code is collected from this url(http://www.codeproject.com/Articles/292159/Javascript-code-to-get-selected-text#) so all the credits goes to him.

Removing Duplicate Entries in Mysql for large dataset

Simple dummy table structure:
CREATE TABLE RssEntry (
rowID INT NOT NULL AUTO_INCREMENT
, rssID INT NOT NULL
, url VARCHAR(254) NOT NULL
, title TEXT
, description TEXT
, PRIMARY KEY (rowID)
, INDEX (rssID)
);

When doing work to remove duplicate entries from a table with a significant number of rows, adding
a temporary, non-unique index on the columns in question can often speed up operations as you go about
removing duplicate entries.

Adding a Non-Unique Index to Speed Up Queries
CREATE INDEX UrlRow ON RssEntry (Url, rowID);

Determining How Many Duplicate URLs Exist in the Data Set:
SELECT COUNT(*), COUNT(*) – COUNT(DISTINCT url) FROM RssEntry;

When removing duplicate entries from a table, first determine which rows having duplicate keys you
wish to keep in the table. For instance, if you are removing a duplicate customer record, will you take the
oldest or newest record? Or will you need to merge the two records? Be sure you have a game plan for what
to do with the redundant data records.

Using GROUP BY to Get Unique URL Records
SELECT MAX(rowID) AS rowID, url FROM RssEntry GROUP BY Url;

Creating a New Table with the Unique Records
CREATE TABLE RssEntry2 (
rowID INT NOT NULL AUTO_INCREMENT
rssID INT NOT NULL
title VARCHAR(255) NOT NULL
url VARCHAR(255) NOT NULL
description TEXT
PRIMARY KEY (rowID)
UNIQUE INDEX Url (url));

Now Insert the data to the new table and delete the old table:
INSERT INTO RssEntry2
SELECT * FROM RssEntry
INNER JOIN (
SELECT MAX(rowID) AS rowID, url
FROM RssEntry
GROUP BY url
) AS uniques
ON RssEntry.rowID = uniques.rowID;

ALTER TABLE RssEntry RENAME TO RssEntry_old;

ALTER TABLE RssEntry2 RENAME TO RssEntry;

These Example was collected from Pro Mysql by Michael Kruckenberg and Jay Pipes…..

Remove Form Decorators From view file in Zend Framework

If you want complete customization of the zend form, it can be done through the Decorators by using addDisplayGroup() method. But for new users it is little bit difficult and need to write lots of code. You can do this in view script.In view script I had remove all the decoration of the default zend form by using this code:

$form = $this->form;
foreach ($form->getElements() as $element)
{
    $element->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label')
            ->removeDecorator('Errors');
}

Removed all the decoration of the form.
To show the errors before the forms:

foreach ($this->form->getMessages() as $elemName => $messages)
{
    foreach ($messages as $message)
    {
        $label = $form->getElement($elemName)->getLabel();
        echo $this->escape($label . ':' . $message);
    }
}

The generate the form in the following way and then organize your form elements as you want.

<form method="<?php echo $form->getMethod() ?>" action="<?php echo $form->getAction() ?>">
          <?php
          echo $form->categoryName;
          echo'<br />';
          echo $form->groupName;
          echo'<br />';
          echo $form->Submit;
          echo'<br />';
          echo $form->Clear;
          ?>          
</form>

How show joomla module in error page.

In error.php page, you need to import the module helper. This can be done by adding this code

jimport( ‘joomla.application.module.helper’ );

Normally we defined module in index.php file jdoc:include type=”modules” name=”menu”
But in error.php it will not work. In error.php you need to call module:

$module = JModuleHelper::getModule( ‘menu’ , ‘Main Menu’ );
$attribs[‘style’] = ‘xhtml’;
echo JModuleHelper::renderModule( $module, $attribs);

where menu = type of the module and
Main Menu = name of the module not ttile.

Change wordpress admin url.

U can change the wp-admin to whatever U want by using the plugin http://wordpress.org/extend/plugins/lockdown-wp-admin/
After installation and activate the plugin, U will see a Lockdown WP menu is added to the admin side bar.Click Lockdown WP. Then U will get an option Hide WP Admin. There is a check box below it.Check the Box.

There is another option WordPress Login URL. Beside this U will see input box.Insert your desired admin folder name in that input box.

At last press the save option button then logout from the admin panel.

Js Arguments

The arguments object is a local variable available within all functions; arguments as a property of Function can no longer be used.

You can refer to a function’s arguments within the function by using the arguments object. This object contains an entry for each argument passed to the function, the first entry’s index starting at 0. For example, if a function is passed three arguments, you can refer to the argument as follows:

arguments[0]
arguments[1]
arguments[2]

The arguments object is not an array. It is similar to an array, but does not have any array properties except length. For example, it does not have the pop method. However it can be converted to a real array:

var args = Array.prototype.slice.call(arguments);

The arguments object is available only within a function body. Attempting to access the arguments object outside a function declaration results in an error.

You will get more details about this topics here:
https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments
**Another well explanation will found here:
http://blog.sebarmeli.com/2010/11/12/understanding-array-prototype-slice-applyarguments/