20 Dec 2015

Laravel Tutorials

Laravel Tutorials: Installation Way : -

1. http://tutsnare.com/how-to-install-laravel-on-windows-xampp/           (Best)
2. http://jafty.com/blog/tag/moving-laravel-from-localhost-to-live-server/
3. http://strauss.io/blog/2015-deploy-laravel-on-shared-hosting.html

17 Dec 2015

Php Script to download files

Smart Php Script to download files -
             http://www.zubrag.com/scripts/download.php

8 Dec 2015

Image Resize & Crop Image Code

https://gist.github.com/netconstructor/2395159

function image_resize_crop ( $src, $w, $h, $dest = null, $override = false, $createNewIfExists = false ) {
     $ext = array_pop ( explode ('.', $src) );
     $filenameSrc = str_replace (".$ext", '', basename($src) );
     $filename = "{$filenameSrc}-{$w}X{$h}";
     $arrayUploadPath = wp_upload_dir();
     $fileUploadSubDir = str_replace(basename($src),'', str_replace($arrayUploadPath['baseurl'], '', $src));
     $fileUploadDir = $arrayUploadPath['basedir'] . $fileUploadSubDir;
   
     if(is_null($dest)) $dest = $fileUploadDir;
   
     $i = null;
     if( ! $override && $createNewIfExists ) {
      $i = 0;
      while ( file_exists("$dest$filename-$i.png") ) $i++;
      $i = '-' . $i;
     }
   
     $fileFullPath = "$dest$filename$i.png";
     $fileFullUrl = $arrayUploadPath['baseurl'] . $fileUploadSubDir . $filename.$i .'.png';
   
     //return cached file if $override == false and file's already there
     if( ! $override && file_exists($fileFullPath) ) return $fileFullUrl;
   
     if( $override ) @unlink($fileFullPath);
   
     switch ($ext) {
      case 'jpg':
      case 'jpeg' : $image = imagecreatefromjpeg($src); break;
      case 'gif' : $image = imagecreatefromgif($src); break;
      case 'png' : $image = imagecreatefrompng($src); break;
      case 'wbmp' :
      case 'bmp': $image = imagecreatefromwbmp($src); break;
      default: $image = imagecreatefromgd2($src);
     }
   
     $width = imagesx($image);
     $height = imagesy($image);
   
     $original_aspect = $width / $height;
     $thumb_aspect = $w / $h;
   
     if ( $original_aspect >= $thumb_aspect ) {
      if( $width > $w ) {
       $new_height = $h;
       $new_width = $width / ($height / $h);
      }else{
       $new_height = $height;
       $new_width = $width;
      }
     
     } else {
        if ( $width > $w ) {
         $new_width = $w;
         $new_height = $height / ($width / $w);
        } else {
         $new_width = $width;
         $new_height = $height;
        }
     }
   
     $thumb = imagecreatetruecolor($w, $h);
     $bg = imagecolorallocate($thumb, 255, 255, 255);
     imagefill($thumb, 0, 0, $bg);
   
     imagecopyresampled($thumb,
            $image,
            0 - ($new_width - $w) / 2,
            0 - ($new_height - $h) / 2,
            0, 0,
            $new_width, $new_height,
            $width, $height);
   
     imagepng($thumb, $fileFullPath, 9);
     imagedestroy($image);
   
     return $fileFullUrl;
    }

6 Dec 2015

PHP OOPS Based Concept-

PHP OOPS Based Concept-
http://www.ibm.com/developerworks/library/os-php-7oohabits/

23 Nov 2015

Best WYSIWYG Editors for Textarea

1.https://www.froala.com/wysiwyg-editor

2. http://www.tinymce.com/tryit/basic.php

26 Oct 2015

Conditional IE Code to add class in body tag in Javascript

Conditional IE Code to add class in body tag in Javascript -

var ms_ie = false;
var ua = window.navigator.userAgent;
var old_ie = ua.indexOf('MSIE ');
var new_ie = ua.indexOf('Trident/');
   
if ((old_ie > -1) || (new_ie > -1)) {
    ms_ie = true;
}
   
if ( ms_ie ) {
    $('body').addClass('ie');
}

12 Oct 2015

Javascript function to parse only integer value


function checkNumberdot(event){
       if ( event.keyCode == 190 || event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
            // Allow: Ctrl+A
           (event.keyCode == 65 && event.ctrlKey === true) ||
            // Allow: home, end, left, right
           (event.keyCode >= 35 && event.keyCode <= 39)) {
                // let it happen, don't do anything
                return;
       }
       else {
           // Ensure that it is a number and stop the keypress
           if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
               event.preventDefault();
           }
       }
}

6 Oct 2015

Ht access Redirect

<IfModule mod_rewrite.c>
  RewriteEngine on
## hide .html extension
# To externally redirect /dir/foo.html to /dir/foo
  RewriteCond %{REQUEST_METHOD}  !=POST
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
  RewriteRule ^ %1 [R=301,L,NC]

## To internally redirect /dir/foo to /dir/foo.html
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^ %{REQUEST_URI}.html [L]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule .* 404.html [L]
</IfModule>

3 Oct 2015

Upload desktop files to Github Repository

Upload desktop files to Github Repository-

http://www.c-sharpcorner.com/UploadFile/65794e/upload-your-source-code-to-github-using-github-application-i/

30 Sept 2015

ht access generator-


http://www.htaccesseditor.com/en.shtml

22 Sept 2015

Use DBO for creating connection to the database

http://culttt.com/2012/10/01/roll-your-own-pdo-php-class/

15 Sept 2015

Current location tracing in google map by javascript

Current location tracing in google map by javascript-

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyAod1PoFkfACW_TrDUYTR7aVUS_JNdfTqo&sensor=true"></script>
<script>
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;

    output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';

    var img = new Image();
    img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=true";

    output.appendChild(img);
  };

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  };

  output.innerHTML = "<p>Locating…</p>";

  navigator.geolocation.getCurrentPosition(success, error);
}
</script>

Mysql Query to Trim white space in the field of table

Mysql Query to Trim white space in the field of table

UPDATE custom_category SET category_title = TRIM( REPLACE( REPLACE( REPLACE( category_title, '\t', '' ) , '\n', '' ) , '\r', '' ) )

9 Sept 2015

Implement Chatting System Using Openfire Server

Implement Chatting System Using Openfire Server -http://xmppchat.blogspot.in/2014/03/create-xmpp-chat-using-php-and.html#comment-form

8 Sept 2015

Facebook Style Messaging System Database design

Facebook Style Messaging System Database design-

http://www.9lessons.info/2013/05/message-conversation-database-design.html

2 Aug 2015

Create word document in Php

Use PhpWord Classes to create word document from in php-

Link-  https://phpword.readthedocs.org/en/latest/

https://htmltodocx.codeplex.com/documentation

9 Jul 2015

Install Cake Php files Step by Step

Steps -

1. Download Composer.exe and install it on windows OS

 While Installing Composer please give the path of php.exe file
  where it prompt for selection of folder

(This php.exe file remain in xampp/php/php.exe)

. once composer installed,

Please run the following command for auto installation of files  in the project folder

2. Type the following command to create the project folder inside of  path: xampp/htdocs

composer create-project --prefer-dist cakephp/app [app_name]



(always keep command path to htdocs folder before write the above command on CMD)

3. Fix intl.dll configuration settings-

a. Uncomment intl.dll line in php.ini file (Path:  xampp/php/php.ini)

b. Copy all files from the (Path:  xampp/php/) starting by name iu*.dll  & paste it to Path: xampp/apache/bin/

5 Jul 2015

Angular JS a simple Application

Angular JS Application

 http://www.informit.com/articles/article.aspx?p=2271482&seqNum=9

http://www.informit.com/articles/article.aspx?p=2271482&seqNum=8

var firstApp = angular.module('firstApp', []); firstApp.controller('FirstController', function($scope) { $scope.first = 'Some'; $scope.last = 'One'; $scope.heading = 'Message: '; $scope.updateMessage = function() { $scope.message = 'Hello ' + $scope.first +' '+ $scope.last + '!'; }; });

8 Jun 2015

Php Code to generate word document in print view from html

Use the following code as a html attribute with the html starting tag
xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"

6 Jun 2015

Create a Word Document from html using Php

Method-1:
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=filename.doc");




.........Complete Html........



Method-2: Download File from Github Read More

5 Jun 2015

Excel file Uploading & data import code from excel(Xlsx) file-

Please Use Excel in Xlsx file format for uploading with SimpleXlsx Class library for data Reading

Php function to resize and crop images

function resize_with_crop($max_width, $max_height, $source_file, $dst_dir, $quality = 80){
    $imgsize = getimagesize($source_file);
    $width = $imgsize[0];
    $height = $imgsize[1];
    $mime = $imgsize['mime'];
 
    switch($mime){
        case 'image/gif':
            $image_create = "imagecreatefromgif";
            $image = "imagegif";
            break;
 
        case 'image/png':
            $image_create = "imagecreatefrompng";
            $image = "imagepng";
            $quality = 7;
            break;
 
        case 'image/jpeg':
            $image_create = "imagecreatefromjpeg";
            $image = "imagejpeg";
            $quality = 80;
            break;
 
        default:
            return false;
            break;
    }
     
    $dst_img = imagecreatetruecolor($max_width, $max_height);
    $src_img = $image_create($source_file);
     
    $width_new = $height * $max_width / $max_height;
    $height_new = $width * $max_height / $max_width;
    
    if($width_new > $width){
        //cut point by height
        $h_point = (($height - $height_new) / 2);
        //copy image
        imagecopyresampled($dst_img, $src_img, 0, 0, 0, $h_point, $max_width, $max_height, $width, $height_new);
    }else{
        //cut point by width
        $w_point = (($width - $width_new) / 2);
        imagecopyresampled($dst_img, $src_img, 0, 0, $w_point, 0, $max_width, $max_height, $width_new, $height);
    }
     
    $image($dst_img, $dst_dir, $quality);
 
    if($dst_img) imagedestroy($dst_img);
    if($src_img) imagedestroy($src_img);
}

resize_with_crop(100, 100, "demo.jpg", "demo.jpg");

Php Function to print array values in level structure

function pr($data) { print('
'.print_r($data, true).'
'); }

Image Resizing and Cropping Code Through GD Library

Provided link describes how a thumbnail can be cropped using GD jQuery Library Url- Read More

16 Jan 2015

htaccess tricks

htaccess tricks- http://enarion.net/web/htaccess/migrate-domains/