Thursday, 25 February 2016

SSRS Interview Questions and Answers for Beginners

SSRS Interview Questions and Answers for Beginners

Question: What is SSRS?
SQL Server Reporting Service(SSRS) is a server-based report generation software systems from Microsoft.


Question: Why SSRS is used?
  1. Generate variety of reports.
  2. Admin use web based interface for generate the report.
  3. You can create very rich reports (Tabular / Matrix / Graphical/Interactive)
  4. Export in variaous format like Excel, PDF, word etc.
  5. It is faster and cheaper.
  6. Efficient reporting
  7. Security integrated


Question: Explain the Reporting Life Cycle of SSRS?
  1. Development of Reports: Design the reports by Developer.
  2. DBA Analyse: DBA check the security and schedule the time for generating the report.
  3. Report Delivery: After generating the report DBA check the list and handover to appropriate person.



Question: What are the Reporting Services components?
  1. Report Designer: Design the report.
  2. Report Sever: Execute the Report.
  3. Report Manager



Question: Difference between SQL Server Reporting Services and Crystal Reports?
SQL Server Reporting Services Crystal Reports
SSRS have a report server Processed by IIS
SSRS is available for Report history snapshots. Caching is available through cache server.
Custom Label NOT available. Custom Label are available


Question: What are different types of roles provided by SSRS?
  1. Browsers
  2. Content Manager
  3. My Reports
  4. Publishers
  5. Report Builder


Question: What are the three different part of RDL file?
  1. Data
  2. Design
  3. Preview



Question: What is RDL?
RDL is a file extension for an XML file used in SSRS.
MIME type: text/xml


Question: What are the different types of data sources in SSRS?
  1. Microsoft SQL Server
  2. OLEDB
  3. Oracle
  4. ODBC
  5. SQL Server Analysis Service
  6. XML
  7. Teradata
  8. Hyperion
  9. SAP Net weaver BI
  10. Report Server Model



Question: In Which format we can export SSRS Reports?
  1. HTML
  2. Excel
  3. PDF
  4. Tiff Image
  5. XML
  6. CSV



Question: What is report snapshot?
It is instance of a report for future reference and its save in server.


Question: What is Tabular Report in SSRS?
Simply display the data using table.
Tabular report is the simplest Report of the SSRS Report.


Question: What is a Matrix in SSRS?
Matrix allows us to create crosstab reports with the variables on rows and columns.


Question:What is Query parameter in SSRS?
SQL Qery can be accepted as parameters.Query parameters begin with the symbol i.e @.


Question: What is the chart in report?
Chart reports are for graphical representation of reports. pie charts and 3D chart are also available.


Question: What are data regions?
Data regions are report items that display repeated rows of summarized information from datasets.


Question: What is Report Builder?
Report Builder is a report authoring environment for business users.


Question: What are alternatives of SSRS at free of cost?
  1. Jasper Reports
  2. JFreeReport
  3. Pentaho
  4. Business Intelligence Reporting Tools
  5. DataVision



Question: What are the Types of SSRS?
  1. Parameterized reports
  2. Ad hoc reports
  3. Clickthrough reports
  4. Drillthrough reports
  5. Subreports
  6. Linked reports
  7. Snapshot reports
  8. Cached reports



Question: What is Data Set in report?
It is set of data which we want to show in report.


Question: What is the report model project?
It is used to create Adhoc reporting.


Question: What is RS.exe utility?
It is used for deploying the report on report server.


Wednesday, 24 February 2016

Google App Engine Free Hosting

Google App Engine

Question: What is Google App Engine?
Google App Engine is a platform as a service (PaaS).
It provides cloud computing platform for developing and hosting web applications in Google-managed data centers.
It is also know as GAE.


Question: When comes stable version of Google App Engine?
1.9.26 / 4 September 2015


Question: Which Programming languages support by GAE ?
Python, Java, Go, PHP and coming others

Question: What is Offical website for GAE?
http://cloud.google.com/appengine


Question: Why GAE is used?
It is used to develop the Web Application, APIs for Mobile, Web Application.


Question: What are different built-in services available?
  1. NoSQL datastores
  2. memcache
  3. user authentication API


Question: What are benefits of using GAI
  1. Load Balancing
  2. Health Checks
  3. Application logging
  4. Automatic Scaling
  5. Automated Security Scanning


Question: What are different IDE available with GAE
Eclipse, IntelliJ, Maven, Git, Jenkins, and PyCharm.


Question: Is it free?
Yes, It is free upto few Level.
Check here for details https://cloud.google.com/appengine/


Question: What is Difference between Google Apps and Google App engine(GAE) ?
Google Apps: It is Web-based hosted software-as-a-service (SaaS).
For Example: gmail.com, Gtalk, Google calender

Google App engine: It is a platform-as-a-service (PaaS).
Here you can host your Website and Website APps.
For Example: It is similar to Amazon Elastic Compute Cloud (EC2).


Question: What are the steps to start with Google App Engine?
  1. Download the App Engine SDK for PHP
  2. Creating a Simple Request Handler
  3. Create the Configuration File
  4. Testing the Application
  5. Iterative Development
  6. Uploading the application
  7. Done
For Details : https://cloud.google.com/appengine/docs/php/



Question: How to start the PHP development in Google Engine App?
  1. Registering an app on GAE. https://appengine.google.com/
  2. Download the Google App Engine from https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP
  3. Starting a project with IDE
  4. create main.php and app.yaml files
  5. Test your application
  6. Upload to Server

http://www.sitepoint.com/google-app-engine-php-getting-started/
for PHP, You have to install Python 2.7 Version From https://www.python.org/downloads/release/python-2711/


Question: Where can i check my PHP Code?
http://localhost:8080/



Monday, 22 February 2016

MySQL Query Optimization Tips and Techniques

MySQL Query Optimization Tips and Techniques

  1. Choosing Which Version of MySQL
  2. Don't join extra tables in MySQL Query.
  3. Only get N records which are going to used. Don't get extra records from table which you are not using.
  4. Don't fetch extra column from table which are not in use.
  5. Don't add spam records in tables
  6. Don't get it overload any table like 1GB Size, In this case shift data to another table.
  7. Get the understanding of normalization.
  8. Use Explain/DESCRIBE to know about table structure and Query. For Example:
  9. DESCRIBE SELECT * FROM `users` WHERE username='web-tech' 
  10. Partition your table (MySQL 5.1). Paritioning is a technique for splitting a large table into several smaller ones by a specific (aggregate) key.
  11. Partition can be achieve in three way 1. RANGE, HASH and List/Key.
  12. Build your indexes to match the queries running. For Example:
    ALTER TABLE `users` ADD INDEX `profile_id` (`profile_id`)
    Know about MySQL Indexing
  13. Use concatination indexing, if required (When searching like below).
    SELECT * FROM table_name  WHERE field_name1='text1' AND field_name2='text2';
  14. No indexing on column which not used in search.
  15. Sometime you need to use OPTIMIZE Table. For Example:
    OPTIMIZE TABLE `users`
    Used for defragment tables and update the InnoDB fulltext index
  16. Full Text Search can be used, if required.
    http://www.web-technology-experts-notes.in/2013/05/mysql-fulltext-search.html

Friday, 19 February 2016

How to detect Mobile Device in PHP? - Simplest way

How to detect Mobile Device in PHP - Simplest way

Question: What does this script do?
It simply detect the request and tells request comes from mobile browser (Mobile devices) OR Web Devices (Desktop, Laptop, Ipad).


Question: What are Server Requirements for this script?
PHP Must be installed.


Question: Why we do need this script?
Sometime we need to give the different response on the behalf of devices.
For Example:
We give 20 records for web browser.
We give 10 records for Mobile browser.


Question: Where we do need this script? Give Example?
We need this script where we change the response on the behalf of devices browser.
For Example:
  1. Different number of record in web and in mobile.
  2. In Responsive website, we hide the extra information which is not displayed in mobile devices. In this case we should also not fetch these details from the server.
  3. Display the different sizes of images on the behalf of device.
  4. If website is not compatiable to mobile devices, Give a good message to users.



Question: How to detect the mobile devices?
$useragent=$_SERVER['HTTP_USER_AGENT'];
$isMobile=0;
if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))){
    $isMobile=1;
}

if($isMobile){
    /** Script For Mobile **/

    /** Script For Mobile **/
}else{
    /** Script For Web**/

    /** Script For Web**/
}



Thursday, 18 February 2016

How can I make SQL Query case sensitive string comparison on MySQL?

How can I make SQL Query case sensitive string comparison on MySQL

In Websites we display the data which fetch from database using string based conditions.
OR
Login Feature / Change password Featured based on string based conditions.
OR
Show the user detils behalf on user slug like "http://example.com/users/user-slug-value"


If you want to make your SQL Query as case sensitive, We have following 3 ways.

  1. Do at MySQL Server Level
    Set Following in /etc/mysql/my.cnf (Works for >MySQL 5.5 only)
    character-set-server=utf8
    collation-server=utf8_bin
  2. Set the column as Case sensitive,For Example
    ALTER TABLE `users` CHANGE `name` `name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
  3. Set the Query as case sensitive, For Example
    SELECT *  FROM `users` WHERE BINARY `name` = 'raJ'



Sunday, 14 February 2016

How to Make Website Responsive for mobile devices?

How to Make Website Responsive for mobile devices?

Question: Why Responsive Web Design is the compulsary for websites?
  1. Recommended By Google: Google have higher Preference for Responsive design as compare to Non-Responsive.
  2. One Website, Many Devices: Single website can be viewable in desktop, laptop, ipad, different sizes of mobile.
  3. Good for SEO
  4. Responsive Website have more page views as compare to non-responsive.
  5. It looks always better in different resolution.

Question: How to check website is responsive OR Not?
https://www.google.com/webmasters/tools/mobile-friendly/


Question: How can i make a existing website responsive?
You can make any website responsive. Just follow the simple steps.

  1. Add Following code in head tag.
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  2. Create a responsive.css file and include in all the pages.
  3. Add Following code in responsive.css
    /* Smaller Resolution Desktops and Laptops */
    @media (max-width: 800px) {
           
           
    }
    /* Smaller devices like Ipad*/
    @media (max-width: 650px) {
    
           
    }
    /* Even Smaller devices like Mobile*/
    @media (max-width: 450px) {
    
           
    }
    /* Smallest Mobile devices */
    @media only screen and (min-device-width: 300px) and (max-device-width: 480px) {
           
           
    }
  4. Now structure is ready, you just need to add css according to devices.
  5. Note: In Responsive design you need to hide extra information of websit



Friday, 12 February 2016

PHP HTML5 video streaming examples

PHP HTML5 video streaming examples

Today, HTML5 video player is being popular. It stream with a given video, If you need to control the streaming from your server script to provide additional facility like ACL/Auth, resume support, sending small videos etc. You can do all with PHP.
Following are PlayVideoStream class, Which you can use
class PlayVideoStream
{
    /** set the private data members **/
    private $path = "";
    private $stream = "";
    private $buffer = 1024000;
    private $start  = -1;
    private $end    = -1;
    private $size   = 0;
    /** set the private data members **/
    
    /** Set the video file path in while creating the object **/
     function __construct($filePath) 
    {
        $this->path = $filePath;
    }
     
    /**
     * Open the file in read mode
     */
    private function open()
    {
        if (!($this->stream = fopen($this->path, 'rb'))) {
            die('Not able to read the file i.e '.$this->path);
        }
         
    }
     
    /**
     * Set  header to serve the video play
     * Here we are getting the mime type dynamically, for this you must enable php_fileinfo extension
     */
    private function setHeader()
    {
        ob_get_clean();
        $result = new finfo();
        $videoType= $result->file($this->path, FILEINFO_MIME_TYPE);  //Get the correct video type
        header("Content-Type: ".$videoType);
        header("Cache-Control: max-age=2592000, public");
        header("Expires: ".gmdate('D, d M Y H:i:s', time()+2592000) . ' GMT');
        header("Last-Modified: ".gmdate('D, d M Y H:i:s', @filemtime($this->path)) . ' GMT' );
        $this->start = 0;
        $this->size  = filesize($this->path);
        $this->end   = $this->size - 1;
        header("Accept-Ranges: 0-".$this->end);
         
        if (isset($_SERVER['HTTP_RANGE'])) {
  
            $c_start = $this->start;
            $c_end = $this->end;
 
            list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
            if (strpos($range, ',') !== false) {
                header('HTTP/1.1 416 Requested Range Not Satisfiable');
                header("Content-Range: bytes $this->start-$this->end/$this->size");
                exit;
            }
            if ($range == '-') {
                $c_start = $this->size - substr($range, 1);
            }else{
                $range = explode('-', $range);
                $c_start = $range[0];
                 
                $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $c_end;
            }
            $c_end = ($c_end > $this->end) ? $this->end : $c_end;
            if ($c_start > $c_end || $c_start > $this->size - 1 || $c_end >= $this->size) {
                header('HTTP/1.1 416 Requested Range Not valid');
                header("Content-Range: bytes $this->start-$this->end/$this->size");
                exit;
            }
            $this->start = $c_start;
            $this->end = $c_end;
            $length = $this->end - $this->start + 1;
            fseek($this->stream, $this->start);
            header('HTTP/1.1 206 Partial Content');
            header("Content-Length: ".$length);
            header("Content-Range: bytes $this->start-$this->end/".$this->size);
        }
        else
        {
            header("Content-Length: ".$this->size);
        }  
         
    }
    
    /**
     * close curretly opened stream
     */
    private function end()
    {
        fclose($this->stream);        die;
    }
     
    /**
     * perform the streaming of calculated range
     */
    private function stream()
    {
        $i = $this->start;
        set_time_limit(0);
        while(!feof($this->stream) && $i <= $this->end) {
            $bytesToRead = $this->buffer;
            if(($i+$bytesToRead) > $this->end) {
                $bytesToRead = $this->end - $i + 1;
            }
            $data = fread($this->stream, $bytesToRead);
            echo $data;
            flush();
            $i += $bytesToRead;
        }
    }
     
    /**
     * Start streaming video content
     */
    function start()
    {
        $this->open();
        $this->setHeader();
        $this->stream();
        $this->end();
    }
}



Question: How to play video with above class?
$filePath='c://wamp/www/project/public_html/videos/myvideoFile.mp4';
//$filePath='c://wamp/www/project/public_html/videos/myvideoFile1.mp3';
//$filePath='c://wamp/www/project/public_html/videos/myvideoFile2.mp4';
//$filePath='c://wamp/www/project/public_html/videos/myvideoFile3.3gp';
$stream = new PlayVideoStream($filePath);
$stream->start();


Wednesday, 10 February 2016

How to Create Thumbnail Images of uploaded image using PHP

How to Create Thumbnail Images of uploaded image using PHP

This tutorial will describe how to create thumbnail images on the fly using PHP while uploading a image. With uploaded of single image you can create different thumbnail with different size of same Image. Here you will Learn how to process a images and create their thumbnails.

System Requirements:
  1. Work for PHP only.
  2. GD library must be installed which you can check with phpinfo() with version of >=GD 2.0.1
  3. Uploading image size should be less than 2MB but if you want to increase then increase the value of "upload_max_filesize", "post_max_size" from php.ini

Code Snippets
   function resize($width, $height, $imageName,$extension) {
        if(empty($width) || empty($height) || empty($imageName) || empty($extension)){
            die('Required parameter is missing');
        }
        $docRoot = getenv("DOCUMENT_ROOT");
        
        /* Get original image x y */
        $tmpNM = $_FILES['files']['tmp_name'];
        
        list($w, $h) = getimagesize($_FILES['files']['tmp_name']);
        /* calculate new image size with ratio */
        $ratio = max($width / $w, $height / $h);
        $h = ceil($height / $ratio);
        $x = ($w - $width / $ratio) / 2;
        $w = ceil($width / $ratio);
        /* new file name */
        $path = $docRoot . '/images/thumb/' . $imageName;

        /* read binary data from image file */
        $imgString = file_get_contents($_FILES['files']['tmp_name']);
        /* create image from string */
        $image = imagecreatefromstring($imgString);
        $tmp = imagecreatetruecolor($width, $height);
        imagecopyresampled($tmp, $image, 0, 0, $x, 0, $width, $height, $w, $h);
        $fileTypes = array('jpg', 'jpeg', 'jpe', 'png', 'bmp', 'gif'); // File extensions
        /* Save image */
        switch ($extension) {
            case 'jpg':
            case 'jpeg':
            case 'jpe':
                imagejpeg($tmp, $path, 100);
                break;
            case 'png':
                imagepng($tmp, $path,0);
                break;
            case 'gif':
                imagegif($tmp, $path, 100);
                break;
            case 'bmp':
                imagewbmp($tmp, $path);
                break;
            default:
                exit;
                break;
        }
        return $path;
        /* cleanup memory */
        imagedestroy($image);
        imagedestroy($tmp);
    }
This function is able to create multiple thumbnail with different sizes of uploaded images.

How to  create thumbnail of 50pxX50px image?
    
    $w='50'; //New image width
    $h='50'; //New image height
    $imageName=$w.'_'.$h.'_'.$_FILES['files']['name']; //Uploaded file Name
    $imageExtensionArray = explode(".", $_FILES['files']['name']);
    $extension=$imageExtensionArray[1];
    $this->resize($w, $h,  "{$imageName}",$extension);

How to create thumbnail of 100pxX100px image?
$w='100'; //New image width
$h='100'; //New image height
$imageName=$w.'_'.$h.'_'.$_FILES['files']['name']; //Uploaded file Name
$imageExtensionArray = explode(".", $_FILES['files']['name']);
$extension=$imageExtensionArray[1];
$this->resize($w, $h,  "{$imageName}",$extension);