Subscribe For Free Updates!

We'll not spam mate! We promise.

Mar 11, 2013

Copy Text From Command prompt and Paste it in Word


Copy Text From Command prompt and Paste it in Word


 First you need to select the text in command prompt. To select the text
Right click on command prompt and select Mark,then select the desired text,it will highlight the text.
Then press Enter to copy the content.
Then open Notepad or Word ,press ctrl+v to paste the content.

Change Font color in DOS

Change Font color in DOS

  You can make DOS as graphic environment using colors for the text and background in DOS.
  To change the text-color in DOS,You can use the following


  COLOR attr
  attr        Specifies color attribute of console output

Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground.  Each digit
can be any of the following values:

    0 = Black       8 = Gray
    1 = Blue        9 = Light Blue
    2 = Green       A = Light Green
    3 = Aqua        B = Light Aqua
    4 = Red         C = Light Red
    5 = Purple      D = Light Purple
    6 = Yellow      E = Light Yellow
    7 = White       F = Bright White
Example: COLOR 1C
If no argument is given, this command restores the color to what it was
when CMD.EXE started.  This value either comes from the current console
window, the /T command line switch or from the DefaultColor registry
value.

Remove autorun.inf Using Command Prompt


Remove autorun.inf Using Command Prompt

  Here is a simple way to delete autorun.inf using command prompt using windows. The function attrib is used to check whether autorun.inf is present in the drive.
  Try the following in command prompt.

Open command prompt
Go to the destination drive using cd destination path and press enter
Type the following code
  1. attrib -a -s -h -r autorun.inf
and press enter.
Now delete autorun.inf.
  2.del autorun.inf.

 Now you can see that autorun.inf has been deleted.

Mar 10, 2013

Extract Zip File using Php


Extract Zip File using Php:
 
You can use Php language to unzip a zip file.   Here is a simple code to unzip a zip file using php. Php has ZipArchive class to do this.

= new ZipArchive;
$zipfile->open('zipfilename.zip');
$zipfile->extractTo('./destination');
$zipfile->close();  ?>

Set Multiple Homepages for Internet Explorer


Set Multiple Homepages for Internet Explorer

Now Internet Explorer 7.0 also allow you to set the multiple home pages like other browsers.You can open all home pages at the same time. You can set your favorite sites and open it at same time.


Follow the given steps to set multiple home pages in Internet Explorer.
·         First open the Internet Explorer 7 and go to the option Tools then click on Internet Options.
·         Select the General tab, here you will get option "To create home page tabs, type each address on its own line" and type the URL in the Home page section.
·         Type one URL in one line then press Enter to type another URL. Press Ok to finish.

Mar 9, 2013

PHP - Check if browser cookies are enabled


PHP - Check if browser cookies are enabled.


At first php reads the cookie data to see if there is already any data saved in them. If not, upon attempting to store some test data, the script refreshes the page. If no result has been returned; it is an obivous indication that cookies are disabled.


if (isset($_COOKIE['stuff'])) {
 echo "cookies enabled";
}
else {
 if(isset($_REQUEST['test_cookies'])) {
 echo "cookies disabled";
 }
 else {
 setcookie("stuff", "1", 0, "/");
 header("Location: $_SERVER['PHP_SELF']?test_cookies=1");
 }
}

Grant permission to user to execute a Stored Procedure - Mysql


Grant permission to user to execute a Stored Procedure - Mysql

If you want to allow user to execute Store procedure then use GRANT EXECUTE keyword

Allow user to execute all stored procedure
GRANT EXECUTE ON *.* TO 'user'@'localhost';

Allow user to execute all stored procedure attached with a single database
GRANT EXECUTE ON db_name.* TO 'user'@'localhost';

Allow user to execute a single stored procedure
GRANT EXECUTE ON db_name.sp TO 'user'@'localhost';

Mysql - Delete duplicate rows based on column value


Mysql - Delete duplicate rows based on column value.

 Mysql - Delete duplicate rows based on column value by below query.

CREATE TABLE temp_name AS SELECT * FROM tab WHERE 1 GROUP BY colname; 
DROP TABLE tab; 
RENAME TABLE temp_name TO tab;

Mysql - Get the record randomly


Mysql - Get the record randomly

 RAND() function is used to get the random record from table.


For Example:
select * from tab_name orderby RAND() limit 0,5;

How to use the OFFSET function in MS Excel.?





OFFSET function to return the value of a cell that is a specified number of rows and columns away from a cell or range of cells that you referenced in an adjacent range.

Enter the following data into a blank Excel worksheet. You will use this data for all sample formulas in this article.
A1: Name    B1: Dept    C1: Age
A2: Henry    B2: 501    C2: 28
A3: Stan    B3: 201    C3: 19
A4: Mary    B4: 101    C4: 22
A5: Larry    B5: 301    C5: 29

Enter the following formulas into cell E2 (or any available blank cell):
=OFFSET(C2,2,-1,1,1)

    C2 - The referenced cell.
    2 - Indicates the number of rows to move. Positive numbers mean move down, and negative numbers mean move up.
    -1 - Indicates the number of columns to move. Positive numbers mean move to the right, and negative numbers mean move to the left.
    1 (second last value) - (Optional.) Indicates how many rows of data to return. This number must be a positive number.
    1 (last value) - (Optional.) Indicates how many columns of data to return. This number must be a positive number.

PHP - Setting session timeout

Session timeout setting is necessary For high-security sites . Php default session timeout time is 20 minutes.

There is 2 functions for change the session timeout.


1. Sets the timeout of a current session and

2. Verifies whether the session is still valid given the specified timeout variable set in above function .


function check_login() {
@session_start();
$expiration_time = intval($_SESSION['session_expiration']);
//if session is still valid
if ($time() < $expiration_time) {
validate_session('600'); // -> make it valid for another 600 secs
return true;
}
 else {
unset($_SESSION['session_expiration']);
return false;

}
}

function validate_session($timeout) {
@session_start();
$_SESSION['session_expiration'] = time() + $timeout;
}




Mar 6, 2013

Facebook flike and fshare combined in single button

In this new flike code we can like and share in same flike button. After click on this like button popup box will appear and ask “Add comments” option. If you need to share your url means you should enter some comments and click “post to facebook” button. If you didn't give the comment it will store in your facebook activity. It'll also shows the count.



The new flike code is :


<div id="fb-root"></div>

<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://www.yoursite.com/" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true" data-font="tahoma"></div>













Mar 3, 2013

Set Time limit for a php script.


Set Time limit for a php script.
If you want to extend the execution time of the script you can use set_time_limit on the page.
The default time limit is 30 seconds


<?php
// script dies after 180 secs
set_time_limit(180);
?>

/**********************************************/
Get random values from database.


SELECT * FROM test_table ORDER BY RAND() limit 20;



This query will return values 20 rows randomly. To make more effecient the random values can be given in the server side scripting language.
/*********************************************************/


Javascript to create zip file




 The Zip file format is very useful for compress the any type of data. we can generate the zip file by using some programming language.
Let us see how to create zip file by using javascript.

1. First we need javascript package jszip.

2. import jszip package in HTML document.

3 use the below code :
      <script type="text/javascript" src="https://raw.github.com/Stuk/jszip/master/jszip.js"></script>
4. Now generate ZIP file like ,

<html>
<head>
    <script type="text/javascript" src="jszip.js"></script>

<script>
 function create_zip() {
    var zip = new JSZip();
    zip.add("hello1.txt", "Hello First World\n");
    zip.add("hello2.txt", "Hello Second World\n");
    content = zip.generate();
    location.href="data:application/zip;base64," + content;
}

</script>

</head>

<body>
     <a href="" onclick="create_zip()">Create Zip</a>
 </body>
</html>


The function create_zip() calls jszip API to generate ZIP file