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>

Feet/Inches to Meters Converter & Lbs to Kgs Converter

 <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8" />   <title>Feet/Inches ⇄...