Showing posts with label Software Development. Show all posts
Showing posts with label Software Development. Show all posts

Tuesday 5 September 2017

Validate Icalendar File or URL




Question: What is Desktop iCalendar?
Desktop iCalendar is a handy desktop calendar for Windows. It stays on your desktop and shows the days of the current month have the events. It can be sync with Google Calendar OR Yahoo Calendar. You can share the calendars with your family and friends with use of the Google OR Yahoo. File format of iCalendar is .ics.


Question: What is use of iCalendar?
iCalendar is a computer file format which allows Internet users to send meeting requests and tasks to other Internet users, via facebook, email. Recipients of the iCalendar data file can respond to the sender easily or counter propose another meeting date/time


Question: Why need of Validate the Icalendar?
When we validate, It make sure us that we are sharing correct and valid file. Also it make sure recipients will get the  task/events once they get.


Question: How to validate Icalendar File OR code snippt.
http://severinghaus.org/projects/icv/


Question: What are Development Tools for Validate Icalender.
Language Library
C/C++ libical
Java iCal4J
Python vObject
Ruby iCalendar
Ruby RiCal

Friday 14 July 2017

Download the Azure SDK for PHP and upload the video in Azure

Download the Azure SDK for PHP and upload the video in Azure

Download the Azure SDK for PHP

  1. Install Git. (If already, move to next)
  2. Create composer.json and add following contents.
    {
             "require": {
               "microsoft/azure-storage": "*"
             }
           }
  3. Download composer.phar in your project root.
  4. Execute following Command.
    php composer.phar install
  5. It will download the Library, which I have tested.



Upload the Media in Azure

  1. Include following files:
    use WindowsAzure\Common\ServicesBuilder;
    use MicrosoftAzure\Storage\Common\ServiceException;
    require_once 'azure/vendor/autoload.php';
  2. Get the Credentials
    $azureUserName='XXXXXXXXXXXX';
    $azureKey='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
    $containter='XXXXXXXXX';
    
  3. Set the Credentias
    $connectionString = "DefaultEndpointsProtocol=http;AccountName={$azureUserName};AccountKey={$azureKey}";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
  4. Upload the File in Azure
    $blobName='textFile.txt';
    $content = fopen('../data/test6.txt', "r");
    try    {
                
                $blobRestProxy->createBlockBlob($containter, $blobName, $content);
                echo 'Uploaded successfully';
            }
            catch(ServiceException $e){
                $code = $e->getCode();
              $e->getMessage();
    
            }

Monday 1 May 2017

What is Web Server?

What is Web Server


Queston: What is Web Server?
A Web server is a program that uses HTTP to serve the data in form Web pages to users.
When client (like browser OR App), hit an http URL (like http://www.web-technology-experts-notes.in/2016/08/what-is-rtmp-rtmpt-rtmpe-rtmpte-and-rtmps-protocol.html), An request goes to Web Server (domain's server), Web server execute the request and return the data.
Note: Dedicated computers and appliances may be referred to as Web servers as well.


Queston: Giv example of Web Server?
A computer can be converted to web server, for this they need to connect to the internet install the web server software.
Following are web server software.
  1. Apache HTTP Server
  2. Microsoft Internet Information Services (IIS)
  3. Apache Tomcat
  4. Nginx
  5. Oracle iPlanet Web Server
  6. Lighttpd
  7. Mobile Web Server
  8. Mongoose (web server)
  9. Jetty
  10. Wamp Server
  11. Boa web server
  12. CERN httpd
  13. Gunicorn
  14. Kloxo-MR
  15. Roxen
  16. AOLserver
  17. Tornado (web server)
  18. Adobe JRun
  19. Hiawatha (web server)
  20. enhydra
  21. WEBrick



Question: What is the difference between web server and application server?
  1. Web Server is a server that serves content to the web using http/https protocol.
    Application server you can write the business login and It can also be work like web server.
  2. Web Server is used for serve the content whereas application server is used for hosts and exposes business logic and processes.



Question: Why port 80 for web services?
Hypertext Transfer Protocol, port 80 is the port (default port) that the server "listens to" or expects to receive from a Web client.
A port can be specified in the range from 0-65536 on the NCSA server.
However, the server administrator configures the server so that only one port number can be recognized.


Question: What is default port for https?
443


Question: What are the different ports used in Web Development?
  1. 20 FTP (File Transfer Protocol)
  2. 21 SFTP (Secure File Transfer Protocol)
  3. 22 Secure Shell (SSH) Connection
  4. 23 Shell connection like ssh but its not reliable.
  5. 25 Simple Mail Transfer Protocol (SMTP)
  6. 50 Hypertext Transfer Protocol (HTTP)
  7. 110 Post Office Protocol (POP)
  8. 143 Internet Message Access Protocol (IMAP)
  9. 443 Hypertext Transfer Protocol over SSL/TLS (HTTPS)
  10. 989 FTP over TLS/SSL



Thursday 27 April 2017

Azure Blob storage Architecture

 Azure Blob storage

Question: What is Azure Blob storage?
Azure Blob storage is a service that stores unstructured large data in the cloud in form of objects/blob.
Blob storage can store any type of file like image, video OR text etc.
Stored data can be accessed through HTTP or HTTPS.


Question: What is Blob?
It is large file like an image, video or binary data.


Question: Why Blob Storage are used?
  1. Streaming Audio/Video.
  2. Storing data for backup and restore.
  3. Store heavy data like images, audio and videos.
  4. Access the data in browser.
  5. Storing files for distributed access.



Question: What is structure of Blob storage?
An account can have one OR More container.
User can store the data in container.
For Example:
One Account 
    Movies (Container 1)
        movie1.mp4 (Blob data)
        movie2.mp4 (Blob data)
        movie3.mp4 (Blob data)

    videos (Container 2)
        video1.mp4 (Blob data)
        video1.mp4 (Blob data)
        video1.mp4 (Blob data)

    photos (Container 3)
        photo1.jpg (Blob data)
        photo2.jpg (Blob data)
        photo3.jpg (Blob data)
        photo4.jpg (Blob data)



Question: How to get azure client Libraries (using composer)?
  1. 1. Create a folder where you want to download the library.
  2. Install composer (If not) php -r "readfile('https://getcomposer.org/installer');" | php
  3. Create a composer.json (with following data)
    {
       "require": {
         "microsoft/windowsazure": "^0.4"
       }
     }
  4. Download the library with following command.
    php composer.phar install



Question: Give a tutorial from where i can do list/add/update/delete the azure blob data?
https://docs.microsoft.com/en-us/azure/storage/storage-php-how-to-use-blobs


Question: In how many programming language code is available?
  1. .NET
  2. Java
  3. Node.js
  4. C++
  5. Python
  6. P?HP
  7. Ruby
  8. iOS
  9. Xamarin



Question: What is mount in linux?
Mounting a filesystem means making the particular filesystem accessible.
When mounting a filesystem it does not matter if the filesystem is a hard disk partition, CD-ROM, floppy, or USB storage device.


Question: Differences between Azure Block Blob and Page Blob?
Block blobs are for your discrete storage objects like jpg's, log files, etc.
Page blobs are for random read/write storage, such as VHD's. Max size 1TB.


Question: What is the maximum length of an Azure blob name?
1024 max character.


Monday 13 March 2017

IMAP Gmail read messages details from inbox

IMAP Gmail read messages details

Check that IMAP is turned on
If Not, Please enable.


Library Code

/** functions used for getting message **/
function flattenParts($messageParts, $flattenedParts = array(), $prefix = '', $index = 1, $fullPrefix = true) {

    foreach($messageParts as $part) {
        $flattenedParts[$prefix.$index] = $part;
        if(isset($part->parts)) {
            if($part->type == 2) {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.', 0, false);
            }
            elseif($fullPrefix) {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix.$index.'.');
            }
            else {
                $flattenedParts = flattenParts($part->parts, $flattenedParts, $prefix);
            }
            unset($flattenedParts[$prefix.$index]->parts);
        }
        $index++;
    }

    return $flattenedParts;
           
}


function getPart($con, $messageNumber, $partNumber, $encoding) {
   
    $data = imap_fetchbody($con, $messageNumber, $partNumber);
    switch($encoding) {
        case 0:
            return $data;
            break; // 7BIT
        case 1:
            return $data;
            break;// 8BIT
        case 2:
            return $data; // BINARY
            break;
        case 3:
            return base64_decode($data);  // BASE64
            break;
        case 4:
            return quoted_printable_decode($data); // QUOTED_PRINTABLE
            break;
        case 5:
            return $data; // OTHER
            break;
    }   
   
}


function getFilenameFromPart($part) {

    $filename = '';
   
    if($part->ifdparameters) {
        foreach($part->dparameters as $object) {
            if(strtolower($object->attribute) == 'filename') {
                $filename = $object->value;
            }
        }
    }

    if(!$filename && $part->ifparameters) {
        foreach($part->parameters as $object) {
            if(strtolower($object->attribute) == 'name') {
                $filename = $object->value;
            }
        }
    }
   
    return $filename;
   
}

/** functions used for getting message **/



How to read specific message
$username = 'mygmail@gmail.com'; //Gmail address
$password = 'gma12#@c'; //Gmail password
error_reporting(0);

 $bodyId=35; //This is message Id

 //Read Message from indebox
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
   
   //Read Message from Trash
    // $hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/Trash';
 
   //Read Message from Sent
 //$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/Sent Mail';




$con = imap_open($hostname, $username, $password);
$messageNumber = $bodyId;
$structure = imap_fetchstructure($con, $messageNumber);
//pr($structure);die;

$message='';
if(!empty($structure->parts)){
 
 $flattenedParts = flattenParts($structure->parts); 
 foreach($flattenedParts as $partNumber => $part) {  
  switch($part->type) {
     
   case 0:
    // the HTML or plain text part of the email
    $message = getPart($con, $messageNumber, $partNumber, $part->encoding);
    // now do something with the message, e.g. render it
      
   break;
    
   case 1:
    // multi-part headers, can ignore
    
   break;
   case 2:
    // attached message headers, can ignore
   break;
    
   case 3: // application
   case 4: // audio
   case 5: // image
   case 6: // video
   case 7: // other
   //pr($part);
   //echo "
$$$$$";
    $filename = getFilenameFromPart($part);
    if($filename) {
     // it's an attachment
     $attachment = getPart($con, $messageNumber, $partNumber, $part->encoding);
        if (empty($filename))
      $filename = $filename;
       
     if (empty($filename))
      $filename = time() . ".dat";
     $folder = "attachment";
     if (!is_dir($folder)) {
      mkdir($folder);
     }
     $fp = fopen("./" . $folder . "/" . $messageNumber . "-" . $filename, "w+");
     fwrite($fp, $filename);
     fclose($fp);
     // now do something with the attachment, e.g. save it somewhere
     $message.='

' . $messageNumber . '-' . $filename . '
'; } break; } } }else{ $message = getPart($con, $messageNumber, 1, $structure->encoding); } if($message){ $message=$message; } echo $message; imap_close($con, CL_EXPUNGE);