Thursday, 27 November 2014

To find url given string and replace with anchor tag in php

<?php
$str = "Hi I am using google.com going http://google.com and 
where in https://google.com ahcinkg http://google.co.in else http://google.co";
$ss = "";
$sd = explode(" ",$str);
//print_r($sd);
$c=count($sd)."
"; $i=0; while($c>$i){ $regex = "((https?|ftp)\:\/\/)?"; // SCHEME $regex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?"; // User and Pass $regex .= "([a-z0-9-.]*)\.([a-z]{2,4})"; // Host or IP $regex .= "(\:[0-9]{2,5})?"; // Port $regex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?"; // Path $regex .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?"; // GET Query $regex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?"; // Anchor // $regexp = '/^[a-zA-Z0-9][a-zA-Z0-9\-\_]+[a-zA-Z0-9]$/'; if (true == preg_match("/^$regex$/", $sd[$i])) { if(!in_array("http", parse_url($sd[$i])) && !in_array("https", parse_url($sd[$i]))) { $s1 ="http://".$sd[$i]; echo $ss ="$sd[$i]  "; }elseif(in_array("http", parse_url($sd[$i])) || in_array("https", parse_url($sd[$i]))) { echo $ss ="$sd[$i]  "; } }else{ echo $sd[$i]."  "; } $i++; } ?>

Thursday, 20 November 2014

Save image from ulr using JAVA

package com.cakes;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class SaveImageFromUrl {
 public static void main(String[] args) throws Exception {
  String imageUrl = "http://www.avajava.com/images/avajavalogo.jpg";
  String destinationFile = "image.jpg";
  saveImage(imageUrl, destinationFile);
 }
 public static void saveImage(String imageUrl, String destinationFile) throws IOException {
  URL url = new URL(imageUrl);
  InputStream is = url.openStream();
  OutputStream os = new FileOutputStream(destinationFile);
  byte[] b = new byte[2048];
  int length;
  while ((length = is.read(b)) != -1) {
   os.write(b, 0, length);
  }
  is.close();
  os.close();
 }
}

Save image from url using php

<?php
$url = "http://www.technotrigger.com/wp-content/uploads/2014/01/house-in-green-field.jpg";
$content = file_get_contents($url);
file_put_contents('flower.jpg', $content);
?>
<img src="flower.jpg">

Friday, 14 November 2014

PHP mail() Function with html content type

<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>

Tuesday, 11 November 2014

Motorola DROID Turbo Specification & expecting launch india


Specifications:
    Operating system :
        Android 4.4.4, KitKat®
    System Architecture/Processor:
        Motorola Mobile Computing System, including Qualcomm® Snapdragon™ 805 processor with 2.7 GHz
        quad-core CPU (APQ8084) with 64-bit memory access Adreno 420 @ 600 MHz GPU
        Natural Language Processor Contextual Computing Processor
    Memory (RAM):
        3 GB (LPDDR3 with 64-bit access)
    Storage:
        32 GB (All models)*
        64 GB (Black Ballistic Nylon only)*
    Rear Camera:
        21 MP (5248x3936) in 4:3
        15.5 MP (2952x5248) in 16:9 f/2.0 aperture
        Tap anywhere to capture
        Dual LED flash
        Auto focus
        4X digital zoom
        Slow motion video
        Burst mode
        Auto HDR
        Panorama
        Tap to focus
    Front Camera:
        2 MP, 1080p HD Video
    Dimensions:
        Black Ballistic Nylon
        Height: 143.5 mm (5.65 inches)
        Width: 73.3 mm (2.89 inches)
        Curve: 8.3-11.2 mm (0.33-0.44 inches)
        
        Metallic Red, Metallic Black
        Height: 143.5 mm (5.65 inches)
        Width: 73.3 mm (2.89 inches)
        Curve: 7.8-10.6 mm (0.31-0.42 inches)
    SIM card:
        Nano-SIM
    Weight:
        Black Ballistic Nylon
        176 grams (6.2 ounces)
        
        Metallic Red, Metallic Black
        169 grams (6.0 ounces)
    Display:
        5.2” 1440p Quad HD 2560x1440 AMOLED, 565 ppi
        Corning® Gorilla® Glass 3
    Battery:
        3900 mAh
        Mixed-usage Up to 48 hours**
        Supports Motorola Turbo Charger (included):
            Up to 8 hours of mixed usage battery in 15 minutes of charging***
    Water-resistant:    Yes
    Networks:   CDMA, EVDO Rev A, 4G LTE, GSM/UMTS/HSPA+
    Bands:
        CDMA/EVDO Rev A (850, 1900 MHz)
        LTE Cat 4 (Bands 2, 3, 4, 7, 13)
        Carrier Aggregation (B4+13)
        GSM/GPRS/EDGE (850, 900, 1800, 1900 MHz)
        UMTS/HSPA+ (850, 900, 1900, 2100 MHz)
    Connectivity:
        Micro USB
        3.5 mm headset jack
    Bluetooth® Technology:  Bluetooth version 4.0 LE
    Wi-Fi:  802.11 a/b/g/n/ac (dual-band capable), mobile hotspot
    Speakers:   Mono, front-ported
    Audio Playback: 
        AAC, AAC+, Enhanced AAC+, AMR-NB, AMR-WB, MIDI, MP3, PCM/WAVE, FLAC, OGG/Vorbis
    Video Playback: H.263, H.264 AVC, H.265, MPEG-4 SP, VP8
    Video Capture:  4K at 24fps, 1080p at 30fps, 720p Slow Motion
    NFC:    Yes
    Mobile Payment Services:
        Softcard
        Google wallet
    Location Services:  A-GPS
    Sensors:    
        Accelerometer, Ambient Light, eCompass, Gyroscope, Hall Effect, Infrared, Proximity
    Base Colors:
        Black Ballistic Nylon
        Metallic Black
        Metallic Red

Wednesday, 5 November 2014

How to disable Ctrl+V (Paste) , Ctrl+X (Cut) and Ctrl+C (Copy) with jQuery?

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
 $(document).ready(function(){
      $('#read').bind("cut copy paste",function(e) {
   e.preventDefault();
   alert(" 'Ctrl+c & Ctrl+x & Ctrl+v has been disabled' ")
      });
   });
});
</script>
<input type="text" id="read" />

How to disable right click in mouse event in jquery?

<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
 $(document).bind('contextmenu', function (e) {
  e.preventDefault();
  alert('Right Click is not allowed');
 });
});
</script>

Tuesday, 4 November 2014

How to lowercase of input field in onkeyup event?

Script Method:
<input type="text" id="ele" onkeyup="this.value=this.value.toLowerCase()" >
CSS Method:
Add style "text-transform:uppercase"
<input type="text" id="ele" style='text-transform:lowercase' >

Monday, 3 November 2014

How to uppercase of input field in onkeyup event?

Script Method:
<input type="text" id="ele" onkeyup="this.value=this.value.toUpperCase()" >
CSS Method:
Add style "text-transform:uppercase"
<input type="text" id="ele" style='text-transform:uppercase' >

Friday, 24 October 2014

How to get the number of rows in a table - tbodyin jquery?

<table id="myTable" cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Birth Date</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>John</td>
      <td>Smith</td>
      <td>03-11-1980</td>
    </tr>
  </tbody>
</table>

Solution:
$("#myTable tbody tr").length - Its wrong.
$("#myTable > tbody > tr").length; - Its right to get solution.

Thursday, 16 October 2014

How To Get a Multiple Rows From JSON Object and Append to the Table

$("#table-list tr").detach();
    $.get(url+"payroll/payroll-ajax.php","id="+arg+"&param=view_loan",function(data){
    var objJSON = eval("(function(){return " + data + ";})()");
    var i=objJSON.length;
    for (var j=0;j<i;j++) {
        k=j+1;
        var newRow =
        "<tr>"
        +"<td>"+k+"</td>"
        +"<td>"+objJSON[j].deduction_date+"</td>"
        +"<td>&#2352;  "+objJSON[j].deduction_amt+"</td>"
        +"</tr>" ;
        $(newRow).appendTo("#table-list tbody");
    }
    $('#view-loan-table-modal').modal('toggle');
    var objJSON="";
    });

This above code is used to get multiple rows from json object.

If the variable data is contains following values.

data=[{"id":"3","loan_id":"8","deduction_date":"2014-07-16 12:54:14","deduction_amt":"16667"},{"id":"9","loan_id":"8","deduction_date":"2014-08-12 10:25:36","deduction_amt":"16667"},{"id":"10","loan_id":"8","deduction_date":"2014-08-12 02:22:53","deduction_amt":"16667"}]

This is JSON object value.

The out put is:

SVG Image Example

SVG IMAGE Examlpe
SVG Image
<html>
<title>SVG Image</title>
<body>
<h1>Sample SVG Image</h1>
<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" stroke="red" stroke-width="2" fill="green" />
</svg>
</body>
</html>

Tuesday, 14 October 2014

List of Android "Secret" Codes, Tips, and Tricks for HTC Mobiles

HTC CODES

Code Description
*#*#3424#*#* HTC function test Program.
*#*#4636#*#* HTC Info menu
*#*#8255#*#* launching GTalk Service Monitor
##3424# Diagnostic mode.
##3282# for EPST.
##8626337# for VOCODER
##33284# Field trial menu.
##786# Reverse Logistics Support.
##7738# Protocol Revision.
##775# Unknown
##2539# Unknown

List of Android "Secret" Codes, Tips, and Tricks for SAMSUNG Mobiles

SAMSUNG CODES

Code Description
*#*#4636#*#* Display information about Phone, Battery and Usage statistics
*#*#7780#*#* Restting your phone to factory state-Only deletes application data and applications
*2767*3855# It's a complete wiping of your mobile also it reinstalls the phones firmware
*#*#34971539#*#* Shows completes information about the camera
*#*#7594#*#* Changing the power button behavior-Enables direct poweroff once the code enabled
*#*#273283*255*663282*#*#* For a quick backup to all your media files
*#*#197328640#*#* Enabling test mode for service activity
*#*#232339#*#* OR *#*#526#*#* Wireless Lan Tests
*#*#232338#*#* Displays Wi-Fi Mac-address
*#*#1472365#*#* For a quick GPS test
*#*#1575#*#* A Different type GPS test
*#*#0283#*#* Packet Loopback test
*#*#0*#*#* LCD display test
*#*#0673#*#* OR *#*#0289#*#* Audio test
*#*#0842#*#* Vibration and Backlight test
*#*#2663#*#* Displays touch-screen version
*#*#2664#*#* Touch-Screen test
*#*#0588#*#* Proximity sensor test
*#*#3264#*#* Ram version
*#*#232331#*#* Bluetooth test
*#*#7262626#*#* Field test
*#*#232337#*# Displays bluetooth device address
*#*#8255#*#* For Google Talk service monitoring
*#*#4986*2650468#*#* PDA, Phone, Hardware, RF Call Date firmware info
*#*#1234#*#* PDA and Phone firmware info
*#*#1111#*#* FTA Software version
*#*#2222#*#* FTA Hardware verion
*#*#44336#*#* Displays Build time and change list number
*#06# Displsys IMEI number
*#*#8351#*#* Enables voice dialing logging mode
*#*#8350#*#* Disables voice dialing logging mode
##778 (+call) Brings up Epst menu

How to check value & its variable type in php?

$i=10; $j="10"; if($i===$j){ ..... } Here we have to check value & its variable type in php

Friday, 10 October 2014

Autocomplete JQuery script full source code example

<script src="http://www.jqueryautocomplete.com/js/jquery/jquery-1.7.1.min.js"></script>
<script src="http://www.jqueryautocomplete.com/js/jquery/jquery.ui.core.min.js"></script>
<script src="http://www.jqueryautocomplete.com/js/jquery/jquery.ui.widget.min.js"></script>
<script src="http://www.jqueryautocomplete.com/js/jquery/jquery.ui.position.min.js"></script>
<script src="http://www.jqueryautocomplete.com/js/jquery/jquery.ui.autocomplete.min.js"></script>
<link rel="stylesheet" href="http://www.jqueryautocomplete.com/js/jquery/smoothness/jquery-ui-1.8.16.custom.css"/>
<script>var data = [
  {"label" : "Aragorn"},
  {"label" : "Arwen"},
  {"label" : "Bilbo Baggins"},
  {"label" : "Boromir"},
  {"label" : "Frodo Baggins"},
  {"label" : "Gandalf"},
  {"label" : "Gimli"},
  {"label" : "Gollum"},
  {"label" : "Legolas"},
  {"label" : "Meriadoc Merry Brandybuck"},
  {"label" : "Peregrin Pippin Took"},
  {"label" : "Samwise Gamgee"}
  ];
</script>
<script>
$(function() {

 $( "#search" ).autocomplete(
 {
   source:data
 })
});
</script>

<input type="text" id="search" />

Thursday, 9 October 2014

Enter Floating Number only

Input field onkeyup check floating values only to allow
onkeyup="if (!isFinite(this.value)) this.value = this.value.replace(/(\s+)?.$/,'')"

How to send e-mail messages using PHP?

<?php
    mail("recipient@example.com",
        "This is the message subject",
        "This is the message body",
        "From: sender@example.com" . "\r\n" . "Content-Type: text/plain; charset=utf-8",
        "-fsender@example.com");
?>

How to change the default directory index page using an .htaccess file?

You can use the DirectoryIndex directive in an .htaccess file 
to specify a custom file or files that the web server looks for 
when a visitor requests a directory. To enable the DirectoryIndex 
directive, use a text editor to modify the .htaccess file as 
follows. Replace filename with the file that you want to 
display whenever a user requests the directory:

DirectoryIndex filename

You can also specify multiple filenames, and the web server
 will search for each file until it finds a match. Consider 
this example directive:

DirectoryIndex index.php index.html index.htm

How to enable and disable directory index listings using an .htaccess file?

Enable directory index listings
In some cases, however, you may want to enable index listings for a directory. 
To do this, use a text editor to add the following line to the .htaccess file:

Options +Indexes

This directive enables standard indexing, where the index listing shows 
only the filenames. You can also enable “fancy” indexing, where the 
index listing shows filenames, their filesizes, and when they were 
last modified. To do this, add the following line to the .htaccess file:

IndexOptions +FancyIndexing

How to protect your file content using htaccess?

# Prevent Apache from serving .htaccess files:
<FilesMatch "^\.htaccess">
    Order allow,deny
    Deny from all
</FilesMatch>

How to enable and disable the PHP magic quotes directive?

When the magic quotes directive is enabled, PHP automatically escapes 
data from HTTP GET and POST requests and cookie data. For example, 
if a user types “hello” (with the quotation marks) in a form, PHP 
automatically escapes the quotation marks and stores the value as 
\“hello\”. To enable this functionality, use a text editor to 
modify the magic quotes directive in the php.ini file as follows:

magic_quotes_gpc = on

To disable this functionality, modify the magic quotes directive in the php.ini file as follows:

magic_quotes_gpc = off

How to enable and disable the PHP register_globals directive?

When the register_globals directive is enabled, PHP creates variables 
automatically from HTML form parameters and cookie data. 
To enable this functionality, use a text editor to modify the 
register_globals directive in the php.ini file as follows:

register_globals = on

To disable this functionality, modify the register_globals 
directive in the php.ini file as follows:

register_globals = off

How to enable and disable the PHP allow_url_fopen directive?

To enable this functionality, use a text editor to modify 
the allow_url_fopen directive in the php.ini file as follows:

allow_url_fopen = on

To disable this functionality, modify the allow_url_fopen 
directive in the php.ini file as follows:

allow_url_fopen = off

How to change the maximum number of input variables for PHP scripts?

PHP obtains input variables from HTML forms (through GET and POST requests), 
as well as from any cookies enabled on a page. 
By default, the maximum number of input variables allowed for 
PHP scripts is set to 1000. You can change this amount by 
adding the max_input_vars directive to a php.ini file.

To change the maximum number of input variables allowed, use a text editor
 to add the max_input_vars directive to your php.ini file. For example,
 to set the maximum number of input variables to 1500, add the following setting:

max_input_vars = 1500

How to enable and disable the expose_php directive?

When the expose_php directive is enabled, PHP includes the following line in 
the HTTP response header when a PHP page is requested 
(the exact version number may differ depending on your configuration):

X-Powered-By: PHP/5.3.27

By default, the expose_php directive is enabled. However, you may not want to 
broadcast the specific PHP version your site is using. Similarly, 
some third-party applications require the expose_php directive to be disabled.

To disable the expose_php directive, use a text editor to modify your php.ini file as follows:

expose_php = off

With the expose_php directive disabled, PHP will not send the X-Powered-By header. 
To re-enable the expose_php directive and send the X-Powered-By header, 
modify your php.ini file as follows:

expose_php = on

How to do copy files from one directory to another directory using php?

Copy files from one directory to another directory using php
copy('foo/test.php', 'bar/test.php');

Saturday, 4 October 2014

Wednesday, 1 October 2014

Easy to integrate Facebook login to your web application

<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
<span id="status"></span>
<script type='text/javascript'>
function statusChangeCallback(response) {
    console.log('statusChangeCallback');
    console.log(response);
    if (response.status === 'connected') {
      testAPI();
    } else if (response.status === 'not_authorized') {
      document.getElementById('status').innerHTML = 'Please log ' +'into this app.';
    } else {
      document.getElementById('status').innerHTML = 'Please log ' +'into Facebook.';
    }
}
function checkLoginState() {
    FB.getLoginStatus(function(response) {  statusChangeCallback(response); });
}

window.fbAsyncInit = function() {
    FB.init({
        appId      : "FB_APP_ID", 
        cookie     : true,  // enable cookies to allow the server to access // the session
        xfbml      : true,  // parse social plugins on this page
        version    : 'v2.1' // use version 2.1
    });
    //FB.getLoginStatus(function(response) {  statusChangeCallback(response); });
};

(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/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
        console.log('Successful login for: ' + response.name);
        var name = response.name;
        var email = response.email;
        document.getElementById('status').innerHTML = 'Thanks for logging in, ' + response.email + '!';
    });
}
</script>

How to resolve auto restart in Android mobile after Factory reset on your device?

Kindly follow steps to follw,
1. First to reset your device
2. To connect internet via wireless or mobile data to configure in Gmail Account first
3. Asking To insert SIM then to insert & restart your device issue solved

Friday, 26 September 2014

Push method for javascript array

JavaScript Array pop() Method
var actors = ["Rajini", "Kamal", "Ajith", "Vijay"];
actors.push("Surya");
The result of fruits will be:
Rajini,Kamal,Ajith,Vijay,Surya

To remove array Last index value Javascript

JavaScript Array pop() Method
var actors = ["Rajini", "Kamal", "Ajith", "Vijay"];
actors.pop();
The result of fruits will be:
Rajini,Kamal,Ajith

Thursday, 25 September 2014

How to add segment insertAfter specific id in jQuery?

<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("<p id=3>Hello world!</p>").insertAfter("#1"); }); }); </script> </head> <body> <button>Insert span element after each p element</button> <p id="1">This is a paragraph.</p> <p>This is another paragraph.</p> </body> </html>

How to connect to MySQL from the command line?

Connect to MySQL from the command line

To connect to MySQL from the command line:

    Log in to your A2 Hosting account using SSH.
    At the command line, type the following command, replacing USERNAME with your username:

    mysql -u USERNAME -p

    At the Enter Password prompt, type your password. When you type the correct password, 
the mysql> prompt appears.

    To display a list of databases, type the following command at the mysql> prompt:

    show databases;

    To access a specific database, type the following command at the mysql> prompt, 
replacing DBNAME with the database that you want to access:

    use DBNAME;

    After you access a database, you can run SQL queries, list tables, and so on. Additionally:
        To view a list of MySQL commands, type help at the mysql> prompt.
        To exit the mysql program, type \q at the mysql> prompt.

To enable/disable for error message in php.ini file

Enable:
display_errors = on
Disable:
display_errors = off

To modify the maximum number of input variables for PHP scripts in php.ini directives

To modify the maximum number of input variables for PHP scripts in php.ini directives
max_input_vars = 1500

To change the memory limit for PHP in php.ini directives

To change for this in php.ini
memory_limit = 256M

To set the PHP error log location in php.ini directives

PHP error log location in php.ini file
Enable:
error_log = /path/filename
Disable
;error_log = /path/filename

To change the PHP time zone setting in php.ini directives

To change the PHP time zone setting in php.ini file
date.timezone = "Europe/Paris"

To change the maximum upload file size for PHP in php.ini directives

In php.ini file change below this,
upload_max_filesize = 20M
post_max_size = 21M

To change execution time in php.ini directives

In php page change execution tin in php.ini file max_execution_time = 100;

Google Translator plugin for Browsers in Js

<script type="text/javascript">function googleTranslateElementInit() {
  var elem = new google.translate.TranslateElement({
    pageLanguage: "ca", 
    layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL,
    autoDisplay: false,
    floatPosition: 0
  });
  elem.onTurnOffLanguageClick = function() {
    var event = document.createEvent("Event");
    event.initEvent("translateExt_disable_lang", true, true);
    document.body.dispatchEvent(event);
  };
  var style = document.createElement("style");
  style.appendChild( document.createTextNode( ".global_header { top: 40px !important; }" ) );
  document.getElementsByTagName( "head" )[ 0 ].appendChild( style );
  elem.showBanner(false);
}</script>

Tuesday, 23 September 2014

Bootstrap select box load in dynamically

$('[data-rel="chosen"],[rel="chosen"]').chosen(); // Call this line of script when even to load bootstrap selectbox

How to convert string to number or integer in js?

var str = "123";
alert(str+"---"+typeof(str));
str = Number(str);
alert(str+"---"+typeof(str));

How to find variable type in js & jquery?

var str = "string";
alert(typeof(str)); //output: string

Input field enter integer only in jQuery

$(document).ready(function () {
    //called when key is pressed in textbox
    $("#quantity").keypress(function (e) {
        //if the letter is not digit then display error and don't type anything
        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
            //display error message
            $("#errmsg").html("Digits Only").show().fadeOut("slow");
            return false;
        }
    });
});

Number :
<input type="text" name="quantity" id="quantity" /> <span id="errmsg"></span>

Wednesday, 17 September 2014

How to get checked values in checkbox in dynamically by using jquery and javascript?

var chkArray = [];
$(".chk:checked").each(function() {
 chkArray.push($(this).val());
});
var selected;
selected = chkArray.join(',') + ",";
if(selected.length > 1){
 alert("You have selected " + selected); 
}else{
 alert("Please at least one of the checkbox"); 
}

Saturday, 13 September 2014

How to remove TV Wizard ads


Windows Vista and Windows 7

    Click Start.
    Select Control Panel.
    Click Uninstall a program.
    Remove TV Wizard.

Windows XP

    Click Start.
    Select Control Panel.
    Click Add or Remove Programs.
    Uninstall the adware program.

Windows 8

    Move the mouse pointer do the lower-left corner of the screen.
    Right-click.
    Select Control Panel.
    Click Uninstall a program.
    Remove the unwanted program.

Friday, 12 September 2014

Thursday, 11 September 2014

Regional Language in Google Transliteration API

<script src="https://www.google.com/jsapi" type="text/javascript">
</script>
<script type="text/javascript">
google.load("elements", "1", {	packages: "transliteration"	});
function onLoad() {
var options = {
sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage: [google.elements.transliteration.LanguageCode.TAMIL],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
var control = new google.elements.transliteration.TransliterationControl(options);
control.makeTransliteratable(['transliterateTextarea']);
}
google.setOnLoadCallback(onLoad);
</script>
<div class="Google-transliterate-Way2blogging">
Type in Hindi (Press Ctrl+g to toggle between English and Tamil)<br>
<textarea id="transliterateTextarea" style="width:600px;height:200px;resize:none;">
</textarea>
<span style="font-weight:bold;font-size:10px;float:right;margin:5px;">
</span>
</div>

Saturday, 6 September 2014

how to find server space in php?

// $ds contains the total number of bytes available on "/"
$ds = disk_total_space("/");

// On Windows:
$ds = disk_total_space("C:");
$ds = disk_total_space("D:");

Hoe to find os by using php?

echo php_uname();
echo PHP_OS;
/* Some possible outputs:
Linux localhost 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686
Linux
FreeBSD localhost 3.2-RELEASE #15: Mon Dec 17 08:46:02 GMT 2001
FreeBSD
Windows NT XN1 5.1 build 2600
WINNT
*/
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    echo 'This is a server using Windows!';
} else {
    echo 'This is a server not using Windows!';
}

Thursday, 4 September 2014

To Calculate distance between two latitude & longitude in php

Method I :

function distance($lat1, $lon1, $lat2, $lon2, $unit) {

  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1))*sin(deg2rad($lat2))+
cos(deg2rad($lat1))*cos(deg2rad($lat2))*cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
    return ($miles * 1.609344);
  } else if ($unit == "N") {
      return ($miles * 0.8684);
    } else {
        return $miles;
      }
}

echo distance(11.01078,76.93433,11.14137,78.59412,10.1, "M") . " Miles
"; echo distance(11.01078,76.93433,11.14137,78.59412,10.1, "K") . " Kilometers
"; echo distance(11.01078,76.93433,11.14137,78.59412,10.1, "N") . " Nautical Miles
"; Method II: function calculateDistance($latitude1, $longitude1, $latitude2, $longitude2) { $theta = $longitude1 - $longitude2; $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); $miles = acos($miles); $miles = rad2deg($miles); $miles = $miles * 60 * 1.1515; return $miles; }

Wednesday, 3 September 2014

How to hidden you IP & proxy?

1. Open Internet Explorer and Select Proxy.
2. Choose Port and Proxy Address, right click on it and copy it.
3. Go to Tools > Internet Options
4. Select Connection Tab and go to LAN Settings.
5. Select Use a proxy server for your LAN in Proxy server
6. Paste Port & Proxy server in Port Box and Address box.
7. Click OK and Exit. 

Resize image by using PHP GD functions

header('Content-Type: image/jpeg');
$w=100;
$h=100;
$filename = 'picture.jpg';
for($i=0;$i<10;$i++){
$rfname="images/re$i.jpg";
resize($filename,$w,$h,$rfname);
}
function resize($filename,$w,$h,$rfname){
list($width, $height) = getimagesize($filename);
$image_p = imagecreatetruecolor($w,$h);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $w, $h, $width, $height);
imagejpeg($image_p,'', 100);
imagejpeg($image_p,$rfname);
}

Basic Linux Commands

1. mkdir - make directories
2. cd - change directories
3. mv- change the name of a directory
   Ex: mv testdir newnamedir
4. pwd - print working directory
   will show you the full path to the directory you are currently in.
   This is very handy to use, especially when performing
   some of the other commands on this page
5. rmdir - Remove an existing directory
6. rm -r
   Removes directories and files within the directories recursively.
7. chown - change file owner and group
8. chmod - change file access permissions
9. reboot - Reboots the system (requires root privileges).
10.ping host - Sends an echo request via TCP/IP to the specified host. A response confirms that the host is operational.

How to read data from excel file using php?

<?php
include 'reader.php';
$excel = new Spreadsheet_Excel_Reader();
?>
<table  border="1">
<?php
$excel->read('sample.xls');//set the excel file name here   
$x=1;
while($x<=$excel->sheets[0]['numRows']) { // reading row by row 
echo "\t<tr>\n";
$y=1;
while($y<=$excel->sheets[0]['numCols']) {// reading column by column 
$cell = isset($excel->sheets[0]['cells'][$x][$y])?$excel->sheets[0]['cells'][$x][$y] :'';
if($cell)
echo "\t\t<td>$cell</td>\n";  // get each cells values
$y++;
}  
echo "\t</tr>\n";
$x++;
}
?>    
</table><br/>

Tuesday, 2 September 2014

Clock running scripts in php with jquery

<div class="col-xs-12 col-sm-12 col-lg-12 cal">
      <p id='demo' class="text-center cal-container"></p> 
   </div>
                       </a>
                       <?php
   
   $current_timestamp = time();
  ?>
                       <script type='text/javascript'>
                        flag = true;
            timer = '';
            phpJavascriptClock();
            setInterval(function(){phpJavascriptClock();},1000);
 
            function phpJavascriptClock()
            {
               
                if ( flag ) {
                    timer = <?php echo $current_timestamp;?>*1000;
                }
                var d = new Date(timer);
                months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 
'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
 
                month_array = new Array('January', 'Febuary', 'March', 
'April', 'May', 'June', 'July', 'Augest', 'September', 'October', 
'November', 'December');
 
                currentYear = d.getFullYear();
                month = d.getMonth();
                var currentMonth = months[month];
                var currentMonth1 = month_array[month];
                var currentDate = d.getDate();
                currentDate = currentDate < 10 ? '0'+currentDate : currentDate;
 
                var hours = d.getHours();
                var minutes = d.getMinutes();
                var seconds = d.getSeconds();
 
                var ampm = hours >= 12 ? 'PM' : 'AM';
                hours = hours % 12;
                hours = hours ? hours : 12; // the hour ’0' should be ’12'
                minutes = minutes < 10 ? '0'+minutes : minutes;
                seconds = seconds < 10 ? '0'+seconds : seconds;
                var strTime = hours + ':' + minutes+ ':' + seconds + ' ' + ampm;
                document.getElementById("demo").innerHTML= currentMonth+' 
' + currentDate+' , ' + currentYear + ' ' + strTime ;
                flag = false;
                timer = timer + 1000;
            }
                       </script>

Monday, 25 August 2014

Json PHP encode value decode in jquery

var objJSON = eval("(function(){return " + resp + ";})()"); // resp is ajax reponse in json encoded by php "objJSON .name" to take values

Thursday, 21 August 2014

Wednesday, 20 August 2014

Factorial program in c using for loop

#include <stdio.h>
int main(){
   int c, n, fact = 1;
   printf("Enter a number to calculate it's factorial\n");
   scanf("%d", &n);
   for (c = 1; c <= n; c++)
      fact = fact * c;
   printf("Factorial of %d = %d\n", n, fact);
   return 0;
}

Factorial program in c using function

#include <stdio.h>
long factorial(int);
int main(){
   int number;
   long fact = 1;
   printf("Enter a number to calculate it's factorial\n");
   scanf("%d", &number);
   printf("%d! = %ld\n", number, factorial(number));
   return 0;
}
long factorial(int n){
   int c;
   long result = 1;
   for (c = 1; c <= n; c++)
      result = result * c;
   return result;
}

Factorial program in c using recursion

#include<stdio.h>
long factorial(int);
int main(){
   int n;
   long f;
   printf("Enter an integer to find factorial\n");
   scanf("%d", &n); 
   if (n < 0)
      printf("Negative integers are not allowed.\n");
   else{
      f = factorial(n);
      printf("%d! = %ld\n", n, f);
   }
   return 0;
}
long factorial(int n){
   if (n == 0)
     return 1;
   else
     return(n * factorial(n-1));
}

Tuesday, 19 August 2014

Page refresh by using Meta tag http-equiv="refresh"

<meta http-equiv="refresh" content="10" url="http://praba-2011.blogspot.in">
content="10" is after 10 secs page will be auto reload

Input field JQuery float validation, decimal validation

$('#price').keyup(function(e){
      var entered_value = $(this).val();
  var regexPattern = /^\d{0,8}(\.\d{1,2})?$/;         
      //Allow only Number as well 0nly 2 digit after dot(.)
      if(regexPattern.test(entered_value)) {
        alert("false") ;  
      } else {
         alert("true");
      }
});

Monday, 18 August 2014

How to take dates between two dates in php?

   $task_to_do = array();
   echo "
"; $s = strtotime("START_DATE"); $d = strtotime("END_DATE"); $dif = 86400; $i=$s; $x=0; while ($i <= $d) { $dat = date("Y-m-d 00:00:00",$i); $t_s = date("Y-m-d 00:00:00",strtotime($dat)); $t_e = date("Y-m-d 23:59:59",strtotime($dat)); $task_to_do[$x]["start_date"] = $t_s; $task_to_do[$x]["end_date"] = $t_e; $i = $i+$dif; $x++; } echo "
";
   print_r($task_to_do);

Sunday, 17 August 2014

Disable Hotlinking Images from Searchengines with htaccess

The following code is used to prevent HotLinking to jpg, jpeg, gif, png, and bmp file types.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?your-websitename.com/.*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ - [F]

Saturday, 16 August 2014

To add watermark image with original image by using php GD functions

$main_img = "Porsche_911_996_Carrera_4S.jpg"; // main big photo / picture
$watermark_img = "watermark.gif"; // use GIF or PNG, JPEG has no tranparency support
$padding = 80; // distance to border in pixels for watermark image
$opacity = 20; // image opacity for transparent watermark
$watermark = imagecreatefromgif($watermark_img); // create watermark
$image = imagecreatefromjpeg($main_img); // create main graphic
if(!$image || !$watermark) die("Error: main image or watermark could not be loaded!");
$watermark_size = getimagesize($watermark_img);
$watermark_width = $watermark_size[0];
$watermark_height = $watermark_size[1];
$image_size = getimagesize($main_img);
$dest_x = $image_size[0] - $watermark_width - $padding+10;
$dest_y = $image_size[1] - $watermark_height - $padding-80;
// copy watermark on main image
imagecopymerge
($image, $watermark,$dest_x, $dest_y, 0, 0, 
$watermark_width, $watermark_height, $opacity);
// print image to screen
header("content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark); 

To Crop image using PHP GD function

cropImage(150,100, 'example.png', 'png', 'image.png');
function cropImage($nw, $nh, $source, $stype, $dest) {
$size = getimagesize($source);
echo "
".$w = 500; echo "
".$h = 400; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); echo "
".$wm = $w/$nw; echo "
".$hm = $h/$nh; echo "
".$h_height = $nh/2; echo "
".$w_height = $nw/2; if($w> $h) { echo "
".$adjusted_width = $w / $hm; echo "
".$half_width = ($adjusted_width / 2)+25; echo "
".$int_width = $half_width - $w_height; imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); } elseif(($w <$h) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); } else { imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h); } imagejpeg($dimg,$dest,100); }

Thursday, 14 August 2014

Bootstrap Tab to set active & show its content in onload or onclick

<div>
    <ul class="nav nav-tabs" id="tabMenu">
        <li class="active"><a href="#Home">Home</a></li>
        <li><a href="#Training">Training</a></li>
        <li class="dropdown">
            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
Placements <b class="caret"></b></a>
            <ul class="dropdown-menu">
                <li><a href="#dotnet">DotNet</a></li>
                <li><a href="#android">Android</a></li>
                <li><a href="#java">Java</a></li>
            </ul>
        </li>
    </ul>
    <div class="tab-content">
        <div id="Home" class="tab-pane fade in active">
            <p>This is the Home page...</p>
        </div>
        <div id="Training" class="tab-pane fade">
            <p>Please select your option regarding on Training...</p>
        </div>
        <div id="dotnet" class="tab-pane fade">
            <p>Welcome to DotNet Placements Section...</p>
        </div>
        <div id="android" class="tab-pane fade">
            <p>Welcome to Android Placements Section...</p>
        </div>
        <div id="java" class="tab-pane fade">
            <p>Welcome to Java Placements Section...</p>
        </div>
    </div>
</div>
Showing Tab targeted by Selector: In order to show our tab manually on start or reload, we have to add the following script to the above code <script type="text/javascript"> $(document).ready(function () { $('#tabMenu a[href="#java"]').tab('show'); // showing the tab targeted by the selector }); </script>
Showing First tab by Default: In order to show the First tab on page reload, Add the below script to the main source <script type="text/javascript"> $(document).ready(function () { $("#tabMenu a:first").tab('show'); // It show the first tab on Reload }); </script>
Showing Last tab by Default: If we need to show the last tab on default, Change the Script like below, <script type="text/javascript"> $(document).ready(function () { $("#tabMenu a:last").tab('show'); // It show the Last tab on Reload }); </script>
Showing Tabs based on Index: We can also show the Default Tab by using Index like in the below script, <script type="text/javascript"> $(document).ready(function () { $("#tabMenu li:eq(1) a").tab('show'); // It shows second tab (0-indexed, like an array) on Reload }); </script>

Wednesday, 13 August 2014

Make symbols with the help of Keyboard

Trademark SymbolAlt+0153
Copyright SymbolAlt+0169©
Registered Trademark SymbolAlt+0174®
Degree SymbolAlt+0176°
Plus or Minus SignAlt+0177±
Paragraph Mark SymbolAlt+0182
Fraction three-fourthsAlt+0190¾
Multiplication SignAlt+0215×
The Cent SignAlt+0162¢
Upside Down Exclamation PointAlt+0161¡
Upside Down Question markAlt+0191¿
Smily faceAlt+1
Black Smily faceAlt+2
SunAlt+15
Female SymbolAlt+12
Male SymbolAlt+11
SpadeAlt+6
ClubAlt+5
HeartAlt+3
DiamondAlt+4
Eighth NoteAlt+13
Beamed Eighth NoteAlt+14
Squareroot Check markAlt+251
Up ArrowAlt+24
Down ArrowAlt+25
Right ArrowAlt+26
Left ArrowAlt+27
Up/Down ArrowAlt+18
Left/Right ArrowAlt+29

Tuesday, 12 August 2014

Datatable jQuery Plugin set order example

$(document).ready(function() {
    $('#example').dataTable( {
        "order": [[ 3, "desc" ]]
    } );
} );
Plugin files:
//code.jquery.com/jquery-1.11.1.min.js
//cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js

Mysql get two column value in get single field

Table : user
--------------
| Id | Name  |
--------------
|  1 | Test  |
|  2 | Test1 |
|  3 | TEst2 |
|  4 | Test3 |
|  5 | Test4 |
|  6 | Test5 |
|  7 | Test6 |
--------------
Query :

selecr concat(id,":",name) as output from user

Output:
------------
| output   |
------------
|  1:Test  |
|  2:Test1 |
|  3:TEst2 |
|  4:Test3 |
|  5:Test4 |
|  6:Test5 |
|  7:Test6 |
------------

Mysql get multi row value in get single field

Table : user
--------------
| Id | Name  |
--------------
|  1 | Test  |
|  2 | Test1 |
|  3 | TEst2 |
|  4 | Test3 |
|  5 | Test4 |
|  6 | Test5 |
|  7 | Test6 |
--------------

Query :
select group_concat(concat(id) SEPARATOR ',') from user

Output:
1,2,3,4,5,6,7

Friday, 8 August 2014

To improve PHP Programming tip in 10 steps

1. Use an SQL Injection Cheat Sheet
2. Know the Difference Between Comparison Operators
3. Shortcut the else
4. Drop those Brackets
5. Favour str_replace() over ereg_replace() and preg_replace()
6. Use Ternary Operators
7. Memcached
8. Use a Framework
9. Use the Suppression Operator Correctly
10. Use isset instead of strlen

To find disk space for my computer & server in php

disk_free_space("directory");

Thursday, 7 August 2014

Get thump image from youtube link

<?php
$url = "YOU_TUBE_URL";   //Ex Youtube link: https://www.youtube.com/watch?v=vL-c_RtYkBE
$queryString = parse_url($url, PHP_URL_QUERY);
parse_str($queryString, $params);
$v = $params['v'];  
if(strlen($v)>0){
 echo "<img src='http://i3.ytimg.com/vi/$v/default.jpg' />";
 echo "<img src='http://i3.ytimg.com/vi/$v/hqdefault.jpg' />";
 echo "<img src='http://i3.ytimg.com/vi/$v/mqdefault.jpg' />";
 echo "<img src='http://i3.ytimg.com/vi/$v/maxresdefault.jpg' />";
}
?>

Browser capture key events & key codes

$(document).keypress(function(e) {
    if (e.which == "13") { 
        //enter pressed 
    }       
});

Micromax Canvas HD Plus A190 Full details with price for Amazon, flipkart and sanpdeal

Price :
Amazon : Rs. 10,923.00/- Buy Online
Flipkart : Rs. 11,289.00/- Buy Online
Snapdeal : Rs. 11,350.00/- Buy Online
OS
OS Name     :  Android Kitkat 4.4.2
OS Version  :  Anroid 4.4
Chipset
Type        :  MTK
Processor  :  1.5GHz Hexa Core
Camera
Flash                             :  Yes
Autofocus                          :  Yes
Resolution, Recording & Playback  :  1920X1088
Camera Resolution                 :  8MP (rear) & 2MP (front)
Key Specs
Screen Size        :  12.7 cm (5)
OS Name              :  Android Kitkat 4.4.2
Processor           :  1.5GHz Hexa Core
Camera Resolution  :  8MP (rear) & 2MP (front)
Battery Capacity     :  2000mAh
Connectivity Options :  3G/Bluetooth/Wi-Fi/USB
DESIGN
Screen Size        :  12.7 cm (5)
Colour Depth        :  262k
Screen Type        :  Capacitive
Screen Resolution  :  1280x720
MULTIMEDIA
Video Resolution           :  1080p
Video Frame Rate           :  30 fps
FM                       :  Yes
Video Formats Supported  :  mp4,3gp
Audio Formats Supported  :  Mp3/MID/AMR/AAC/WAV
BATTERY
Battery Capacity  :  2000mAh
Standby Time     :  250hr*
Talktime        :  7hr*
Connectivity
Frequency Band        :  WCDMA 900/2100MHz GSM 850/900/1800/1900MHz
Network                 :  3G
HSPA                    :  Yes
Wi-Fi                 :  Yes
Bluetooth              :  V3.0
Location                : GPS  :  Yes
Connectivity Options  :  3G/Bluetooth/Wi-Fi/USB
Storage
ROM                 :  8GB
Internal Memory     :  4.76GB (mass storage)
Expandable Memory  :  32 GB
Sensors              :  G-Sensor, proximitysensor, light sensor
RAM                 :  1GB
Connectors
USB V           :  Micro
Dual SIM Support  :  Yes
Ear Jack        :  3.5 mm
Applications
Applications  :  Mi live, get it, Games club,Mi games, kingsoft-office , games (giga jump, jelly, marbles)


Wednesday, 6 August 2014

Wordwrap in CS3 Html style

<?php
$t="LognTEXTLognTEXTLognTEXTLognTEXTLognTEXTLognTEXTLognTEXTLognTEXTLognTEXT";
echo "$t<br/>";
?>
<div style="width:100px;border:1px solid red;word-wrap: break-word;">
<?php echo $t; ?>
</div>

Times ago jQuery plugin

<script type='text/javascript' src="jquery.min.js"></script>
<script type='text/javascript' src="timeago/jquery.timeago.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
$("abbr.timeago").timeago();
$("time.timeago").timeago();
});
</script>
<abbr class="timeago" title="July 17, 2008">6 years ago</abbr>

SMTP Host name by different mail server

Gmail: smtp.gmail.com
Yahoomail: smtp.mail.yahoo.com
Godaddy: relay-hosting.secureserver.net
Rediff: smtp.rediffmail.com

Get address by using lattitude and longitude Google APi

<?php

echo getAddress("28.6100", "77.2300");

function getaddress($lat,$lng)
{
$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';
$json = @file_get_contents($url);
$data=json_decode($json);
$status = $data->status;
if($status=="OK")
return $data->results[0]->formatted_address;
else
return false;
}
?>

First Data Global Gateway - Payment gateway integration

lt;?php ini_set('display_errors', '1'); $url = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v11'; $data = array( "gateway_id" => "xxxxxxx", //YOUR GATEWAY ID "password" => "xxxxxxxx", // YOOUR GATEWAY PASSWORD "transaction_type" => "00", "amount" => "11", "cardholder_name" => "Test", "cc_number" => "4111111111111111", "cc_expiry" => "0314" ); $data_string= json_encode($data); // Initializing curl $ch = curl_init( $url ); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=UTF-8;','Accept: application/json' )); // Getting results $result = curl_exec($ch); // Getting jSON result string $data_string = json_decode($result); if ($data_string) { if ($data_string->bank_resp_code == '100') { print('Approved!'); } else { print($data_string->bank_message); } } else { print($result); } ?>

Facebook embed your website

Instead, I would try this site, iframehost, to install your Iframe and embed your blog.
Log in to Facebook.
Go to this page.
Click “install page tab.”
Choose the business page to which you want to embed your blog.
Click “authorize the tab application.”
In the bottom left-hand corner of the text box that appears, change the drop down menu to “only me.”
Beside “page source” click on “URL” and enter the URL you want to embed.
Change the tab name and image. You will also be able to change these later.
Click “Save Settings” and then allow the application to access your business page.
Go to your business page and check that your tab is working appropriately.

Ref: http://writerswin.com/new-options-to-embed-your-website-on-facebook/ 

By using PHP unzip zip files with source code

<?php
$zip = new ZipArchive;
$res = $zip->open('demo.zip');
if ($res === TRUE) {
$zip->extractTo('test/');
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
}
?>

Tuesday, 5 August 2014

Bootstrap Off Canvas nav toggle viewing windows size

$(document).ready(function () {
$('[data-toggle=offcanvas]').click(function () {
$('.row-offcanvas').toggleClass('active')
});
});

Monday, 4 August 2014

How to determine if an ip within specific range or not by using php?

$lower = "0.0.0.0.0";
$upper = "255.255.255.255";
$ip = "0.0.0.10";
$lower_dec = (float)sprintf("%u",ip2long($lower));
$upper_dec = (float)sprintf("%u",ip2long($upper));
$ip_dec = (float)sprintf("%u",ip2long($ip));
if( ($ip_dec>=$lower_dec) && ($ip_dec<=$upper_dec) ){
echo "True";
}else{
echo "False";
}

Thursday, 31 July 2014

How to list files in Main directory & its Sub directory in dynamically in php?

$directory = substr(DIR_BASE,0,-1);
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
$i=1;
while($it->valid()) {
 if (!$it->isDot()) {
    echo "$i\n";
    echo 'SubPathName: ' . $it->getSubPathName() . "\n";
    echo 'SubPath:     ' . $it->getSubPath() . "\n";
    echo 'Key:         ' . $it->key() . "\n\n";
    $i++;
 }
 $it->next();
}

How to create Zip file using php?

$zip = new ZipArchive();
$zip_name = time().".zip"; // Zip name
$zip->open($zip_name, ZipArchive::CREATE);
$zip->addFile('test.php');
$zip->close();
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
unlink($zip_name);

How to export My Sql Database Backup in php?

$backuptime = "DB_Backup_".DB_NAME."-".time().".sql";
//$backuptime = DB_NAME.".sql";
$data["db_file_name"] = $backuptime;
$insert = $CommonObj->insert_query("db_backup",$data);
$str = "";
$show_tables = "show tables from ".DB_NAME;
$tables = $db->query($show_tables);
if($tables){
   while($row = mysql_fetch_assoc($tables)){
      $table = $row["Tables_in_".DB_NAME];
      $show_each_tables = "show create table ".$table;
      $each_tables  =  $db->query($show_each_tables);
      $each_tables = mysql_fetch_assoc($each_tables);
      $str .= $each_tables["Create Table"];
      $str .= ";\n\n";
      $show_column = "SHOW COLUMNS FROM $table";
      $column  =  $db->query($show_column);
      $get_val_query = "select * from $table";
      $get_val  =  $db->query($get_val_query);
      if($column && mysql_num_rows($get_val)>0){
         $str .= "INSERT INTO `$table` (";
         while($cols = mysql_fetch_assoc($column)){
            $str .= '`'.$cols["Field"].'`, ';
         }
         $str = substr($str,0,-2);
         $str .=  ") VALUES \n";
      }
      if($get_val && mysql_num_rows($get_val)>0){
         while($vals = mysql_fetch_assoc($get_val)){
            $str .= "( ";
            foreach($vals as $k=>$v){
               $v= mysql_real_escape_string($v);
               $str  .= '"'.$v.'", ';
            }
            $str = substr($str,0,-2);
            $str .= "),\n";
         }
         $str = substr($str,0,-2);
      }
      $str .= ";\n\n";
   }
}
$handle = fopen(DIR_DB.$backuptime,'w+');
fwrite($handle,$str);
fclose($handle);

Wednesday, 30 July 2014

Google Shorten URL :: To make Bitly Url

<?php
$postData = array('longUrl' => "http://softwarepottikadai.com");
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
//As the API is on https, set the value for CURLOPT_SSL_VERIFYPEER to false.
// This will stop cURL from verifying the SSL certificate.
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
$json = json_decode($response);
curl_close($curlObj);
echo $json->id;
?>

Friday, 18 July 2014

Google finance calculator - Currency conversion in php

<?
function currency($from, $to, $amount){
   $content = file_get_contents('https://www.google.com/finance/converter?a='.$amount.'&from='.$from.'&to='.$to);
   $doc = new DOMDocument;
   @$doc->loadHTML($content);
   $xpath = new DOMXpath($doc);
   $result = $xpath->query('//*[@id="currency_converter_result"]/span')->item(0)->nodeValue;
   $converted = str_replace(' '.$to, '', $result);
   return round($converted, 3);
}

echo $currentval = currency('USD', 'INR', 1); // returns 0.7216
?>
 AED => United Arab Emirates Dirham (AED)
    AFN => Afghan Afghani (AFN)
    ALL => Albanian Lek (ALL)
    AMD => Armenian Dram (AMD)
    ANG => Netherlands Antillean Guilder (ANG)
    AOA => Angolan Kwanza (AOA)
    ARS => Argentine Peso (ARS)
    AUD => Australian Dollar (A$)
    AWG => Aruban Florin (AWG)
    AZN => Azerbaijani Manat (AZN)
    BAM => Bosnia-Herzegovina Convertible Mark (BAM)
    BBD => Barbadian Dollar (BBD)
    BDT => Bangladeshi Taka (BDT)
    BGN => Bulgarian Lev (BGN)
    BHD => Bahraini Dinar (BHD)
    BIF => Burundian Franc (BIF)
    BMD => Bermudan Dollar (BMD)
    BND => Brunei Dollar (BND)
    BOB => Bolivian Boliviano (BOB)
    BRL => Brazilian Real (R$)
    BSD => Bahamian Dollar (BSD)
    BTN => Bhutanese Ngultrum (BTN)
    BWP => Botswanan Pula (BWP)
    BYR => Belarusian Ruble (BYR)
    BZD => Belize Dollar (BZD)
    CAD => Canadian Dollar (CA$)
    CDF => Congolese Franc (CDF)
    CHF => Swiss Franc (CHF)
    CLF => Chilean Unit of Account (UF) (CLF)
    CLP => Chilean Peso (CLP)
    CNH => CNH (CNH)
    CNY => Chinese Yuan (CN¥)
    COP => Colombian Peso (COP)
    CRC => Costa Rican Colón (CRC)
    CUP => Cuban Peso (CUP)
    CVE => Cape Verdean Escudo (CVE)
    CZK => Czech Republic Koruna (CZK)
    DEM => German Mark (DEM)
    DJF => Djiboutian Franc (DJF)
    DKK => Danish Krone (DKK)
    DOP => Dominican Peso (DOP)
    DZD => Algerian Dinar (DZD)
    EGP => Egyptian Pound (EGP)
    ERN => Eritrean Nakfa (ERN)
    ETB => Ethiopian Birr (ETB)
    EUR => Euro (€)
    FIM => Finnish Markka (FIM)
    FJD => Fijian Dollar (FJD)
    FKP => Falkland Islands Pound (FKP)
    FRF => French Franc (FRF)
    GBP => British Pound Sterling (£)
    GEL => Georgian Lari (GEL)
    GHS => Ghanaian Cedi (GHS)
    GIP => Gibraltar Pound (GIP)
    GMD => Gambian Dalasi (GMD)
    GNF => Guinean Franc (GNF)
    GTQ => Guatemalan Quetzal (GTQ)
    GYD => Guyanaese Dollar (GYD)
    HKD => Hong Kong Dollar (HK$)
    HNL => Honduran Lempira (HNL)
    HRK => Croatian Kuna (HRK)
    HTG => Haitian Gourde (HTG)
    HUF => Hungarian Forint (HUF)
    IDR => Indonesian Rupiah (IDR)
    IEP => Irish Pound (IEP)
    ILS => Israeli New Sheqel (₪)
    INR => Indian Rupee (Rs.)
    IQD => Iraqi Dinar (IQD)
    IRR => Iranian Rial (IRR)
    ISK => Icelandic Króna (ISK)
    ITL => Italian Lira (ITL)
    JMD => Jamaican Dollar (JMD)
    JOD => Jordanian Dinar (JOD)
    JPY => Japanese Yen (¥)
    KES => Kenyan Shilling (KES)
    KGS => Kyrgystani Som (KGS)
    KHR => Cambodian Riel (KHR)
    KMF => Comorian Franc (KMF)
    KPW => North Korean Won (KPW)
    KRW => South Korean Won (₩)
    KWD => Kuwaiti Dinar (KWD)
    KYD => Cayman Islands Dollar (KYD)
    KZT => Kazakhstani Tenge (KZT)
    LAK => Laotian Kip (LAK)
    LBP => Lebanese Pound (LBP)
    LKR => Sri Lankan Rupee (LKR)
    LRD => Liberian Dollar (LRD)
    LSL => Lesotho Loti (LSL)
    LTL => Lithuanian Litas (LTL)
    LVL => Latvian Lats (LVL)
    LYD => Libyan Dinar (LYD)
    MAD => Moroccan Dirham (MAD)
    MDL => Moldovan Leu (MDL)
    MGA => Malagasy Ariary (MGA)
    MKD => Macedonian Denar (MKD)
    MMK => Myanma Kyat (MMK)
    MNT => Mongolian Tugrik (MNT)
    MOP => Macanese Pataca (MOP)
    MRO => Mauritanian Ouguiya (MRO)
    MUR => Mauritian Rupee (MUR)
    MVR => Maldivian Rufiyaa (MVR)
    MWK => Malawian Kwacha (MWK)
    MXN => Mexican Peso (MX$)
    MYR => Malaysian Ringgit (MYR)
    MZN => Mozambican Metical (MZN)
    NAD => Namibian Dollar (NAD)
    NGN => Nigerian Naira (NGN)
    NIO => Nicaraguan Córdoba (NIO)
    NOK => Norwegian Krone (NOK)
    NPR => Nepalese Rupee (NPR)
    NZD => New Zealand Dollar (NZ$)
    OMR => Omani Rial (OMR)
    PAB => Panamanian Balboa (PAB)
    PEN => Peruvian Nuevo Sol (PEN)
    PGK => Papua New Guinean Kina (PGK)
    PHP => Philippine Peso (Php)
    PKG => PKG (PKG)
    PKR => Pakistani Rupee (PKR)
    PLN => Polish Zloty (PLN)
    PYG => Paraguayan Guarani (PYG)
    QAR => Qatari Rial (QAR)
    RON => Romanian Leu (RON)
    RSD => Serbian Dinar (RSD)
    RUB => Russian Ruble (RUB)
    RWF => Rwandan Franc (RWF)
    SAR => Saudi Riyal (SAR)
    SBD => Solomon Islands Dollar (SBD)
    SCR => Seychellois Rupee (SCR)
    SDG => Sudanese Pound (SDG)
    SEK => Swedish Krona (SEK)
    SGD => Singapore Dollar (SGD)
    SHP => Saint Helena Pound (SHP)
    SLL => Sierra Leonean Leone (SLL)
    SOS => Somali Shilling (SOS)
    SRD => Surinamese Dollar (SRD)
    STD => São Tomé and Príncipe Dobra (STD)
    SVC => Salvadoran Colón (SVC)
    SYP => Syrian Pound (SYP)
    SZL => Swazi Lilangeni (SZL)
    THB => Thai Baht (฿)
    TJS => Tajikistani Somoni (TJS)
    TMT => Turkmenistani Manat (TMT)
    TND => Tunisian Dinar (TND)
    TOP => Tongan Paʻanga (TOP)
    TRY => Turkish Lira (TRY)
    TTD => Trinidad and Tobago Dollar (TTD)
    TWD => New Taiwan Dollar (NT$)
    TZS => Tanzanian Shilling (TZS)
    UAH => Ukrainian Hryvnia (UAH)
    UGX => Ugandan Shilling (UGX)
    USD => US Dollar ($)
    UYU => Uruguayan Peso (UYU)
    UZS => Uzbekistan Som (UZS)
    VEF => Venezuelan Bolívar (VEF)
    VND => Vietnamese Dong (₫)
    VUV => Vanuatu Vatu (VUV)
    WST => Samoan Tala (WST)
    XAF => CFA Franc BEAC (FCFA)
    XCD => East Caribbean Dollar (EC$)
    XDR => Special Drawing Rights (XDR)
    XOF => CFA Franc BCEAO (CFA)
    XPF => CFP Franc (CFPF)
    YER => Yemeni Rial (YER)
    ZAR => South African Rand (ZAR)
    ZMK => Zambian Kwacha (1968-2012) (ZMK)
    ZMW => Zambian Kwacha (ZMW)
    ZWL => Zimbabwean Dollar (2009) (ZWL

How to get IP based country,state,currency and countrycode and Internet connection Provider and lattitude & longitude in PHP?

<?php
echo getipaddress();
function getipaddress(){
   $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
   print_r($xml);
   $ccode=$xml->geoplugin_countryCode;
   return $ccode;
}
function getRealIpAddr(){
   if (!empty($_SERVER['HTTP_CLIENT_IP']))  
   {
  $ip=$_SERVER['HTTP_CLIENT_IP'];
 }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
 {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }else{
  $ip=$_SERVER['REMOTE_ADDR'];
 }
 //$ip="YOUR IP";
 return $ip;
}
   
echo "<hr>";
$details = ip_details(getRealIpAddr());
print_r($details);

function ip_details($ip) {
    $json = file_get_contents("http://ipinfo.io/{$ip}");
    $details = json_decode($json);
    return $details;
}


?>

Wednesday, 16 July 2014

How to download your profile from facebook?


1. Login to your FB account in http://facebook.com
2. Goto your Account -> Settings
3. Click Download as Copy & you have get mail from fb registered account
4. Check you mail the subject is " Your Facebook download is ready" and click the link
Ex: https://www.facebook.com/dyi?x=**************
5. You have get you full profile & uploaded photos, videos & wall everything will be get

Kaththi mp3 songs free download - Vijay, Samantha, AR Murugadoss, Anirudh Ravichander

ISAIMINI.COM Download

Tuesday, 15 July 2014

CSS Message bog show automatically & hide

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<style type="text/css">
.message{ width: 90%; margin-left:auto; margin-right:auto; position: relative; top: 5px; }
</style>
<?php if(isset($_SESSION["e_msg"]) && $_SESSION["e_msg"]!=""){ ?>
<div class="alert alert-danger alert-error message" style='display:none;'>
   <a href="#" class="close" data-dismiss="alert">×</a>
   <strong>Error!</strong> <?php echo $_SESSION["e_msg"]; ?>
</div>
<script type='text/javascript'>
$( document ).ready(function() {    $(".alert-danger").fadeIn( "slow" );  });
setTimeout(function(){ $(".alert-danger").slideToggle( "slow" ); },3000);</script>
<?php
unset($_SESSION['e_msg']);
}
if(isset($_SESSION["i_msg"]) && $_SESSION["i_msg"]!=""){ ?>
<div class="alert alert-info message" style='display:none;'>
   <a href="#" class="close" data-dismiss="alert">×</a>
   <strong>Note!</strong> <?php echo $_SESSION["i_msg"]; ?>
</div>
<script type='text/javascript'>
$( document ).ready(function() {    $(".alert-info").fadeIn( "slow" );  });
setTimeout(function(){ $(".alert-info").slideToggle( "slow" ); },3000);</script>
<?php
unset($_SESSION['i_msg']);
}
if(isset($_SESSION["w_msg"]) && $_SESSION["w_msg"]!=""){ ?>
<div class="alert alert-warning warning message " style='display:none;'>
    <a href="#" class="close" data-dismiss="alert">×</a>
    <strong>Warning!</strong>  <?php echo $_SESSION["w_msg"]; ?>
</div>
<script type='text/javascript'>
$( document ).ready(function() {    $(".alert-warning").fadeIn( "slow" );  });
setTimeout(function(){ $(".alert-warning").slideToggle( "slow" ); },3000);</script>
<?php
unset($_SESSION['w_msg']);
}
if(isset($_SESSION["s_msg"]) && $_SESSION["s_msg"]!=""){ ?>

<div class="alert alert-success message" style='display:none;'>
   <a href="#" class="close" data-dismiss="alert">×</a>
   <strong>Success!</strong>  <?php echo $_SESSION["s_msg"]; ?>
</div>
<script type='text/javascript'>
$( document ).ready(function() {    $(".alert-success").fadeIn( "slow" );  });
setTimeout(function(){ $(".alert-success").slideToggle( "slow" ); },3000);</script>
<?php
unset($_SESSION['s_msg']);
}
?>

Friday, 11 July 2014

How to calculate no of working days in php?

function getWorkingDays($startDate, $endDate){
   $begin=strtotime($startDate);
   $end=strtotime($endDate);
   if($begin>$end){
     echo "tartdate is in the future! 
"; return 0; }else{ $no_days=0; $weekends=0; while($begin<=$end){ $no_days++; // no of days in the given interval $what_day=date("N",$begin); if($what_day>6) { // 6 and 7 are weekend days $weekends++; }; $begin+=86400; // +1 day }; $working_days=$no_days-$weekends; return $working_days; } }

How to find last day of month in jquery datetime picker?

function getLastDayOfYearAndMonth(year, month){
    return(new Date((new Date(year, month + 1, 1)) - 1)).getDate();
}

Thursday, 10 July 2014

How to find your mobile number?

உங்கள் à®®ொபைல் எண் மறந்துவிட்டதா?
***********************************

"உங்கள் à®®ொபைல் எண் திà®°ையில் தோன்à®± à®…à®´ுத்துà®™்கள்"

Idea சேவையைப் பயன்படுத்துபவர்கள் *1#

Bsnl சேவையைப் பயன்படுத்துபவர்கள் *888#

Aircel சேவையைப் பயன்படுத்துபவர்கள் *131#

Videocon சேவையைப் பயன்படுத்துபவர்கள் *1#

Airtel சேவையைப் பயன்படுத்துபவர்கள் *121*9#

Reliance சேவையைப் பயன்படுத்துபவர்கள் *1#

Virgin Mobile சேவையைப் பயன்படுத்துபவர்கள் *1#

Vodafone சேவையைப் பயன்படுத்துபவர்கள் *131*0#

Tata DoComo சேவையைப் பயன்படுத்துபவர்கள் *580#

Thursday, 3 July 2014

How to make Bitly Url using Google API

$GoogleApiKey = $appkey;
$postData = array('longUrl' => $currenturl, 'key' =>$GoogleApiKey);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url');
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
//As the API is on https, set the value for CURLOPT_SSL_VERIFYPEER to false. This will stop cURL from verifying the SSL certificate.
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
$json = json_decode($response);
curl_close($curlObj);
return $json->id;

Wednesday, 2 July 2014

How to find prime numbers between two numbers with sliding effect?

<?php
$min = 0;
$max = 10;
if(isset($_POST) && isset($_POST["prime"])){
$min = (isset($_POST["min"])) ?$_POST["min"]:$min;
$max = (isset($_POST["max"])) ?$_POST["max"]:$max;
}
?>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<style type='text/css'>
  aside{
    font-size: 14px;
    font-family:Arial;
  }
  .main{
    margin: 0 auto;width:90%;
    
    -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;
    border:1px solid #000000;background-color:#0D020D;
    padding: 20px;
  }
  #prime_no{
    height: 200px;
    overflow-y: scroll;
  }
  .main1{
    margin: 0 auto;width:90%;
    height:150px;
    -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;
    border:1px solid #000000;background-color:#0D020D;
    padding: 20px;
  }
  .oran{
    border:0; color:#f6931f; font-weight:bold;
  }
  .white{
    border:0; color:#FFFFFF; font-weight:bold;
  }
  .mgroup{
    /*border:1px solid red;*/
    margin:0 auto;
    width:50%;
    padding:10px;
  }
  .mgroup label{
    border:0; color:#FFFFFF; font-weight:bold;
  }

  .css_button {
    margin : 0px 0px 0px 150px;
    
    font-family:Arial;
    font-weight:normal;
    -moz-border-radius: 8px;
    -webkit-border-radius: 8px;
    border-radius: 8px;
    border: 1px solid #3866A3;
    padding: 9px 18px;
    text-shadow:1px 1px 0px #5E5E5E;
    -moz-box-shadow:inset 1px 1px 0px 0px #BEE2F9;
    -webkit-box-shadow:inset 1px 1px 0px 0px #BEE2F9;
    box-shadow:inset 1px 1px 0px 0px #BEE2F9;
    font-weight:normal;
    text-decoration:none;
    cursor: pointer;
    background:-webkit-linear-gradient(90deg, #468ccf 5%, #63b8ee 100%);
    background:-moz-linear-gradient(90deg, #468ccf 5%, #63b8ee 100%);
    background:-ms-linear-gradient(90deg, #468ccf 5%, #63b8ee 100%);
    background:linear-gradient(180deg, #63b8ee 5%, #468ccf 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#63b8ee', endColorstr='#468ccf');
    /*background-color:#468ccf;*/
    color:#FFFFFF;
    display:inline-block;
  }
  .css_button:hover {
    background:-webkit-linear-gradient(90deg, #63b8ee 5%, #468ccf 100%);
    background:-moz-linear-gradient(90deg, #63b8ee 5%, #468ccf 100%);
    background:-ms-linear-gradient(90deg, #63b8ee 5%, #468ccf 100%);
    background:linear-gradient(180deg, #468ccf 5%, #63b8ee 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#468ccf', endColorstr='#63b8ee');
    /*background-color:#63b8ee;*/
  }
  .css_button:active {
    position:relative;
    top:1px;
  }

  .textbox { 
    background: white;
    font-weight:bold;
    border: 1px solid #ffa853; 
    border-radius: 3px; 
    box-shadow: 0 0 3px 1px #ffa853; 
    color: #666; 
    outline: none; 
    height:23px; 
    width: 100px; 
  } 
</style>
<aside>
  <center><h3>Prime Number</h3></center>
<div class='main'>
  <div id="range" class="oran"></div><br>
  <div id="slider-range"></div><br>
  <div id="prime_no" class="white"></div><br>
</div>
<br>
<div class='main1'>
  <form action="" method="post" onsubmit="return ck_min();">
    <div class="mgroup">
            <label for="name">Minimum Value</label>
    <input type='text' placeholder="Min Value" maxlength='5' class="textbox" name='min' id='min'  onkeyup = "if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')">    
        </div>
    <div class="mgroup">
            <label for="name">Minimum Value</label>
    <input type='text' placeholder="Max Value" maxlength='5' class="textbox" name='max' id='max'  onkeyup = "if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')">
        </div>
    <div class="mgroup">
            <input type='submit' class="css_button" value='Enter' name='prime'>
        </div>
  </form>
</div>
  <script type='text/javascript'>
  var minval = <?php echo $min; ?>;
  var maxval = <?php echo $max; ?>;
  $(function() {
    isPrime(minval,maxval);   
    $( "#slider-range" ).slider({
    range: true,
    min: minval,
    max: maxval,
    values: [ minval, maxval ],
    slide: function( event, ui ) {
      $( "#range" ).html( "Min No : " + ui.values[ 0 ] + " - Max No : " + ui.values[ 1 ] );
      isPrime(ui.values[ 0 ],ui.values[ 1 ]);
    }
    });
    $( "#range" ).html( "Max No : " + $( "#slider-range" ).slider( "values", 0 ) + " - Min No : " + $( "#slider-range" ).slider( "values", 1 ) );
  });
  
  function ck_min(){
    var mi = $("#min").val();
    var mx = $("#max").val();
    mi = parseInt(mi);
    mx = parseInt(mx);
    if (mi && mx) {
    
    if (mi > mx) {
     alert("Min val should be less than Max val and Max Val should be greater than Min Val");
     return false;
    }else{
     return true;
    }
    }else{
    return false;
    }
    
  }
  function isPrime(a,b) {
    var temp = new Array();   
    var x=0
      for(i=a; i<=b; i++){
    if(isPrimeno(i)){
      temp[x]=i;
      x++;
    }
    }
    var str = "Prime No : ";
    for(y=0;y<temp.length;y++){
    str += temp[y];
    if (temp.length-1>y) {
      str += " , ";
    }
    
    }
    $("#prime_no").html(str);
    
  }
  
  function isPrimeno(numb){
    for(var i=2; i<= Math.sqrt(numb); i++){
    if(numb%i ==0){
      return false;
    }
    }
    return true;
  }
  
  </script>
</aside>

Monday, 30 June 2014

MySQL IF function

MySQL IF function
Syntax: IF(expr,if_true_expr,if_false_expr)
Example:
SELECT IF(1 = 2,'true','false'); -- false
SELECT IF(1 = 1,' true','false'); -- true

MySQL Query GROUP BY day / month / year

Method I :
SELECT count('id') as cnt,order_status,order_date FROM `product_order` 
group by MONTH(order_date) 
Method II :
SELECT count('id') as cnt,order_status,order_date FROM `product_order` 
group by DATE_FORMAT(order_date, '%m')
Method III:
SELECT SQL_NO_CACHE YEAR(record_date), MONTH(record_date), COUNT(*) FROM stats 
GROUP BY YEAR(record_date)*100 + MONTH(record_date)

SELECT YEAR(date_column), MONTH(date_column), COUNT(*)
FROM date_table
GROUP BY DATE_FORMAT(date_column, '%Y%m')

Google Maps Image APIs

Get Google Map Image for specific latittude & longitude
Static Maps API

<img src="http://maps.google.com/staticmap?size=500x400&markers=11,78&zoom=12">


<img src="http://maps.googleapis.com/maps/api/streetview?size=200x200&location=40.720032,-73.988354&heading=235">

Saturday, 28 June 2014

How to generate passoword in php with specific length?

function generate_password( $length = 8 ) {
  $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  $password = substr( str_shuffle( $chars ), 0, $length );
  return $password;
 }

How to get n digit random numers in php?

function generate_number_code( $length = 8 ) {
  $chars = "0123456789";
  $password = substr( str_shuffle( $chars ), 0, $length );
  return $password;
 }

JS get random Numbers

function getRandom(length) {
 var rand = Math.floor(Math.pow(10, length-1) + Math.random() * 9 * Math.pow(10, length-1));
 return rand;
}

PHP - Mysql Get date between two date ranges

Fetching records between two date ranges
Between two years
SELECT * FROM `dt_tb` WHERE year( dt2 ) between 2004 and 2005
Between two month ranges. 
SELECT * FROM `dt_tb` WHERE month(dt) between '02' and '08'

SELECT * FROM `dt_tb` WHERE month(dt) between '02' and '08' and year(dt) between 2004 and 2005

Between two date ranges
SELECT * FROM `dt_tb` WHERE dt BETWEEN '2005-01-01' AND '2005-12-31' 

PHP - Header redirect issue Occur in Live Server

Method I

<?php ob_start(); if(isset($_GET['elimina_id'])){ if (in_array($_GET['elimina_id'], $_SESSION['cart']) ) { $index = (array_keys($_SESSION['cart'], $_GET['elimina_id'])); $i = $index[0]; unset($_SESSION['cart'][$i]); header('location: cart.php'); } } ob_end_flush(); ?>

Method II

HTML: <meta http-equiv="refresh" content="0;url=http://www.site.com/cart.php"> JavaScript #1: <script>window.location = "http://www.site.com/cart.php";</script> JavaScript #2: <script>window.navigate("http://www.site.com/cart.php");</script>

Wednesday, 25 June 2014

Set Position of Bootstrap Modal Popup

@media screen and (min-width: 768px) {
    .modal-dialog {
        left: 50%;
        right: auto;
        width: 624px;
    }
}
.modal-dialog{
position: absolute;
left: 50%;
//now you must set a margin left under zero - value is a half width your window
margin-left: -312px;
// this same situation is with height - example
height: 500px;
top: 50%;
margin-top: -250px;
}