Saturday, 28 July 2018

Laravel Basics for Beginners

Laravel Basics for Beginners

Question: What is Laravel?
Laravel is a open-source PHP framework used for Developing the websites.


Question: What developed the Laravel?
Taylor Otwell.


Question: When Laravel was launched?
June 2011


Question: What is current stable version of Laravel?
Version 5.2.36 dated June 6, 2016


Question: In which language it was written?
PHP.


Question: What is offical website URL of Laravel?
laravel.com.


Question: Is Laravel an Open Source?
Yes, Download the framework and use as per your requirement


Question: How to install Laravel?
We can install the Laravel in following ways.
  1. Laravel Installer
  2. Composer Create-Project



Question: Explain about Laravel Project?
Laravel is one of the most popular PHP frameworks used for Web Development.
This framework is with expressive, elegant syntax.
It is based on model–view–controller (MVC) architectural pattern.


Question: What are the feature of Laravel5.0?
  1. Method injection
  2. Contracts
  3. Route caching
  4. Events object
  5. Multiple file system
  6. Authentication Scaffolding
  7. dotenv – Environmental Detection
  8. Laravel Scheduler



Question: What is system requirement for installation of Laravel 5.2 (latest version)?
  1. PHP >= 5.5.9
  2. OpenSSL PHP Extension
  3. PDO PHP Extension
  4. Mbstring PHP Extension
  5. Tokenizer PHP Extension



Question: How to install Laravel5.0/Laravel 5.1 with detail steps?
Install Laravel 5.0
Install Laravel 5.1


Friday, 27 July 2018

Google speech API with Punctuation and word timestamp in PHP

Google speech api with Punctuation and word timestamp

Question: What is Speech Recognition?
Google Cloud Speech-to-Text enables developers to convert audio to text by applying powerful neural network models in an easy to use API. The API recognizes 120 languages and variants.


Question: Does it provide Speech Recognition for real-time streaming?
Yes, Its provide for both real-time streaming or pre-recorded audio.


Question: What are the different languages for it provides speech to text?
https://cloud.google.com/speech-to-text/docs/languages


Question: Does it return immediately?
Cloud Speech-to-Text can stream text results, immediately returning text as it’s recognized from streaming audio or as the user is speaking.
For short audio (less than a min), It return results.

For Longer audio, Its take time (1min -20) depend on audio file length.


Question: What are different Models for Speech to Text?
  1. command_and_search: Best for short queries such as voice commands or voice search.
  2. phone_call: Best for audio that originated from a phone call .
  3. video: Best for audio that originated from video or includes multiple speakers
  4. default: Best for audio that is not one of the specific audio models.

You can set model in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('model'=>'video')
); 



Question: What are the pricing for speech to text?
https://cloud.google.com/speech-to-text/pricing



Question: How to set private key in the environment?
putenv('GOOGLE_APPLICATION_CREDENTIALS=priviate_key_json.json'); 



Question: How to get punctuation in results?
punctuation are the character which we use in written. for example comma(,), perios(.), question mark?.
You can get the punctuation in transcription results by providing enableWordTimeOffsets=true in the config.

for example:
You can set enableWordTimeOffsets in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('enableWordTimeOffsets'=>true,'model'=>'video')
); 



Question: What is office link for speech to text?
https://cloud.google.com/speech-to-text/


Question: What is Github link for speech to text?
https://github.com/GoogleCloudPlatform/google-cloud-php-speech


Question: How to install the SDK for speech to text?
php composer.phar require google/cloud-speech



Question: How to get the transcription for small audio file.?
$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);

// Recognize the speech in an audio file.
$results = $speech->recognize(
   $audioFilePath,
);

foreach ($results as $result) {
    echo $result->topAlternative()['transcript'] . "\n";
}   



Question: How to get the transcription for heavy audio file.?
for heavy files, make sure you have already uploaded to google cloud and you have path.

$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
                $speech = new V1p1beta1\SpeechClient([
                    'languageCode' => 'en-US',
                ]);
                $config = new V1p1beta1\RecognitionConfig();
                $config->setLanguageCode('en-US');
                $config->setEnableWordTimeOffsets(true);
                $config->setEnableAutomaticPunctuation(true);
                $config->setModel('video');
                
                $audio = new V1p1beta1\RecognitionAudio();
                $audio->setUri($audioFilePath);
                $operation = $speech->longRunningRecognize($config, $audio);
                
              $result['operation']=$operation->getName();//operation name
 

You can get the results by using Operation Name.
$operationName='194790781308823479';
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);
$operation = $speech->operation($operationName);

$isComplete = $operation->isComplete();
if($isComplete){
$results=$operation->results();
}



Wednesday, 25 July 2018

AWS interview questions and answers for 1 year experienced

AWS interview questions and answers for 1 year experienced

Question: What is the difference between Amazon S3 and Amazon EC2 instance?
Amazon S3: It is just storage service where you can upload photo, video, audio, pdf etc any type of files upto 5 terabytes (5Tb).
It store data as a object, you can't install any software like MS office, VLC player, Adobe etc.

You can import/export data from/to S3 and also can access via cloudfront.

EC2 instance: Launching a EC2 instance is similar a create virtual computer (windows, linux) where you can install software unlike S3. You can customize the configuration like volume(storage), RAM, CPU etc.


Question: How to copy files from one bucket to another?
  1. Login to SSH using ip address and ppk file.
  2. Make sure, it have AWS S3 access privilege
  3. Now just execute following command
    aws s3 sync s3://source-bucket s3://destination-bucket --exclude *.tmp
    



Question: Can we change the availability zone of an existing EC2 t1.micro instance?
No, you can not do.
for this, you need to launch new instance from existing instance.



Question: What is Availability Zones?
Amazon EC2 is hosted in world-wide.
These locations are composed of regions and Availability Zones.
Each region has multiple, isolated locations known as Availability Zones.


Question: How to move files directly from one S3 account to another?
Bucket Explorer works on Mac
S3 Browser works on windows.



Question: AWS Difference between a snapshot and AMI?
A snapshot is of an EBS volume where you save at a certain point of time.
An AMI is similar, but its for the EC2 instances themselves. you can create a AMI but can't do snapshot.


Question: What is the maximum length of a filename in S3?
1024 characters.



Question: How to move a domain from Godaddy to AWS Route 53? =>Login on your aws console
=>Click on Route 53
=>Create Hosted Zone
=>Select your new created host title
=>click "Go to Record Sets", take note of the nameservers;

=>Login on your Godaddy account
=>Select your domain
=>Go to Nameservers and click SetNameservers;
=>paste all the four you took from Go to Record Sets;


Question: How to transfer files between from AWS ec2 to S3
aws s3 cp myfolder s3://mybucket/myfolder --recursive



Question: How to transfer files between from S3 to EC2
aws s3 cp s3://mybucket/myfolder myfolder  --recursive



Question: Question: What is private hosted zone?
A private hosted zone is a container that holds information about how you want Amazon Route 53 to respond to DNS queries for a domain



Question: What is the AWS Storage Gateway service?
The AWS Storage Gateway service enables hybrid storage between on-premises environments and the AWS Cloud.


Tuesday, 24 July 2018

AWS Interview Questions and Answers

AWS interview questions and answers

Question: What are different http status code?
    [100] => Continue
    [101] => Switching Protocols
    [200] => OK
    [201] => Created
    [202] => Accepted
    [203] => Non-Authoritative Information
    [204] => No Content
    [205] => Reset Content
    [206] => Partial Content
    [300] => Multiple Choices
    [301] => Moved Permanently
    [302] => Found
    [303] => See Other
    [304] => Not Modified
    [305] => Use Proxy
    [307] => Temporary Redirect
    [400] => Bad Request
    [401] => Unauthorized
    [402] => Payment Required
    [403] => Forbidden
    [404] => Not Found
    [405] => Method Not Allowed
    [406] => Not Acceptable
    [407] => Proxy Authentication Required
    [408] => Request Timeout
    [409] => Conflict
    [410] => Gone
    [411] => Length Required
    [412] => Precondition Failed
    [413] => Request Entity Too Large
    [414] => Request-URI Too Long
    [415] => Unsupported Media Type
    [416] => Requested Range Not Satisfiable
    [417] => Expectation Failed
    [500] => Internal Server Error
    [501] => Not Implemented
    [502] => Bad Gateway
    [503] => Service Unavailable
    [504] => Gateway Timeout
    [505] => HTTP Version Not Supported
    [509] => Bandwidth Limit Exceeded



Question: How to safely upgrade an Amazon EC2 instance from t1.micro to large?
Create a snapshot of your current image
Once snopshot done, then new to launch new instance.
Simply launch it as a large instance at that point.



Question: How to get the instance id from within an ec2 instance?
Login to EC2,and execute following command
wget -q -O - http://169.254.169.254/latest/meta-data/instance-id



Question: How to setup up FTP on Amazon Cloud Server?
https://stackoverflow.com/questions/7052875/setting-up-ftp-on-amazon-cloud-server



Question: What data is stored in Ephemeral Storage of Amazon EC2 instance?
When you mount your EBS volume at /myNewWebsite, then anything not in /myNewWebsite will be lost.


Question: Difference between EC2 and Elastic Beanstalk?
EC2
EC2 service that allows you to create a Ec2 instance in the AWS. You pay by the hour. you can create n instance and do the setting for each instance.

Elastic Beanstalk
Elastic Beanstalk is one layer of abstraction away from the EC2 layer.
In Beanstalk will setup an "environment" for you that can contain a number of EC2 instances, an optional database, as well as a few other AWS components such as a Elastic Load Balancer, Auto-Scaling Group, Security Group etc.



Question: What is difference between Lightsail and EC2?
EC2
EC2 service that allows you to create a Ec2 instance in the AWS. You pay by the hour. you can create n instance and do the setting for each instance.

Lightsail
Lightsail is designed to be the easiest way to launch and manage a virtual private server with AWS.
Lightsail plans include everything you need to start for your project – a virtual machine, SSD-based storage, data transfer, DNS management, and a static IP – for a low, predictable price.



Question: How to make clone of EC2?
You make an AMI of an existing instance, and then launch other instances using that AMI.



Question: .htaccess not working apache with my EC2 instance?
  1. Login to SSH
  2. Configure Apache mod_rewrite a2enmod rewrite
  3. add the following code to /etc/apache2/sites-available/default
    AllowOverride All
  4. Restart apache
    /etc/init.d/apache2 restart



Question: What happens when I reboot an EC2 instance?
Its similar as we reboot the system. None of data is deleted.
As per cost, no change in cost as they start charging when start instance and stop when terminate the instance.



Question: What is difference between Fixed Performance / Burstable Performance Instances?
AWS EC2 has 2 different type of instances: Fixed Performance Instances(for example M3, C3 etc) and Burstable Performance Instances (For example T2).

Fixed Performance Instances provides a consistent CPU performance whereas Burstable Performance Instances provide a baseline CPU performance under normal workload and when the workload increase on server then increase the CPU performance.



Question: What is CPU Credit?
CPU Credit regulates the amount of "CPU performance" can be increased under workload.
You can spend this CPU Credit to increase the CPU performance during the Burst period.
100% of CPU performance for 5 minutes, you will spend 5(i.e. 5*1.0) CPU Credit.


Question: What is CPU Credit Balance?
is simply the amount of CPU Credit available in your account at any moment.


Wednesday, 18 July 2018

AWS Tutorial Terminology page 8

AWS Tutorial Terminology page 8

Question: What is Amazon Resource Names (ARNs)?
Amazon Resource Names (ARNs) uniquely identify AWS resources across all of AWS resources, such as in IAM policies, Amazon Relational Database Service (Amazon RDS) tags.


Question: Give few sample of ARN Format?

arn:aws:elasticbeanstalk:us-east-1:123456789012:environment/My App/MyEnvironment


arn:aws:iam::123456789012:user/David


arn:aws:rds:eu-west-1:123456789012:db:mysql-db


arn:aws:s3:::my_corporate_bucket/exampleobject.png



Question: Explain syntax of ARN Format?
arn:partition:service:region:account-id:resource

arn:It is static
partition: Standard AWS regions the partition is aws.
service: The service namespace that identifies the AWS product like Amazon S3, IAM, or Amazon RDS.
region: Region of the service like west-1, west-2,
account: Account id from where its generated.
resource: The content of this part of the ARN varies by service. It often includes an indicator of the type of resource.



Question: What is Elastic ip address?
An Elastic IP address is a static IPv4 address designed for dynamic cloud computing.
An Elastic IP address is associated with your AWS account.


Question: What is public hosted zone?
A public hosted zone is a container that holds information about how you want to route traffic on the internet for a domain, such as example.com


Question: What is private hosted zone?
A private hosted zone is a container that holds information about how you want Amazon Route 53 to respond to DNS queries for a domain


Question: What is Amazon RDS Read Replicas?
Amazon RDS Read Replicas provide enhanced performance and durability for database which makes elastically scale out beyond the capacity constraints of a single DB instance for read-heavy database workloads.


You can create one or more replicas and serve high-volume application read traffic from multiple copies of your data.
Read replicas are available in Amazon RDS for MySQL, MariaDB, and PostgreSQL as well as Amazon Aurora.



Question: What is Amazon RDS Multi-AZ Deployments?
Amazon RDS Multi-AZ deployments provide enhanced availability and durability for Database (DB) Instances, making them a natural fit for production database workloads. When you provision a Multi-AZ DB Instance, Amazon RDS automatically creates a primary DB Instance and synchronously replicates the data to a standby instance in a different Availability Zone (AZ). Each AZ runs on its own physically distinct, independent infrastructure, and is engineered to be highly reliable.


Question: What AWS Key Management Service (KMS)?
KMS is a managed service where you can create and control the encryption keys used to encrypt your data, and uses FIPS 140-2 validated hardware security modules. KML is integrated with most other AWS services to help you protect the data you store with these services.


Question: What is difference between Amazon S3, EBS and EFS ?
Amazon S3: Amazon S3 stores data as objects. Each object in the storage contains a header with associated sequence of bytes from 0 byte to 5 TB.
EBS: EBS stores data as blocks of the same size and organizes as similar to a traditional file system, you can use it with EC2 instance.
EFS: EBS may be good for setting up a drive for virtual machines and and S3 is good for storage and EFS is good for both.

Amazon S3 Amazon EBS Amazon EFS
Can be publicly accessible
Web interface
Object Storage
Scalable
Slower than EBS and EFS
Accessible only via the given EC2 Machine
File System interface
Block Storage
Hardly scalable
Faster than S3 and EFS
Accessible via several EC2 machines and AWS services
Web and file system interface
Object storage
Scalable
Faster than S3, slower than EBS
Good for storing backups Is meant to be EC2 drive Good for shareable applications and workloads



Tuesday, 17 July 2018

AWS Tutorial Terminology page 7

AWS Tutorial Terminology page 7

Question: What is Amazon EBS Snapshots?
You can back up the data on your Amazon EBS volumes to Amazon S3 at any point of time knows as snapshots.

Snapshots are incremental backups, which means that only the blocks on the device that have changed after your most recent snapshot are saved.

When you delete a snapshot, only the data unique to that snapshot is removed.
Each snapshot contains all of the information needed to restore your data.



Question: What is enhanced networking on Linux?
Enhanced networking uses single root I/O virtualization (SR-IOV) to provide high-performance networking capabilities on supported instance types. SR-IOV is a method of device virtualization that provides higher I/O performance and lower CPU utilization when compared to traditional virtualized network interfaces.



Question: What is Spot Instances?
A Spot Instance is an unused EC2 instance that is available for less than the On-Demand price.
Because Spot Instances enable you to request unused EC2 instances at steep discounts, you can lower your Amazon EC2 costs significantly.


The hourly price for a Spot Instance is called a Spot price.The Spot price of each instance type in each Availability Zone is set by Amazon EC2, and adjusted gradually based on the long-term supply of and demand for Spot Instances.Your Spot Instance runs whenever capacity is available and the maximum price per hour for your request exceeds the Spot price.



Question: What is Amazon elastic map reduce?
Amazon EMR processes "big data" across a Hadoop cluster of virtual servers on Amazon Elastic Compute Cloud (EC2) and Amazon Simple Storage Service (S3).


Question: What is the AWS Storage Gateway service?
The AWS Storage Gateway service enables hybrid storage between on-premises environments and the AWS Cloud.


Question: Difference between Gateway cached volume and stored volume?
In the cached mode, your primary data is written to S3, while retaining your frequently accessed data locally in a cache for low-latency.
Whereas in the stored mode, your primary data is stored locally and your entire dataset is available for low-latency access while asynchronously backed up to AWS.


Question: What protection was on AWS Storage Gateway?
All data transferred between any type of gateway appliance and AWS storage is encrypted using SSL.
data stored by AWS Storage Gateway in S3 is encrypted server-side with Amazon S3-Managed Encryption Keys (SSE-S3).


Question: What is file gateway?
AWS Storage Gateway service that provides your applications a file interface to seamlessly store files as objects in Amazon S3, and access them, using industry standard file protocols.


Question:What is Amazon kinesis?
Amazon Kinesis is collect and process large streams of data records in real time.
The processed records can be sent to dashboards, used to send alerts and advertising strategies, or send data to a variety of other AWS services.


Question: What are benefits of Amazon Kinesis?
  1. Kinesis Video Streams to capture, process, and store video streams for analytics and machine learning.
  2. Kinesis Data Streams to build custom applications that analyze data streams using popular stream processing frameworks.
  3. Kinesis Data Firehose to load data streams into AWS data stores.
  4. Kinesis Data Analytics to analyze data streams with SQL.



Question: What is IOPS?
IOPS is the standard unit of measurement for I/O (Input/Output) operations per second.


Question: Amazon EBS General Purpose (SSD) volume type?
Elastic Block storage(EBS) General purpose (SSD) is default volume in EC2.
It is suitable for application from small to medium-sized databases, development and test environments, and boot volumes.


Question: What is Aws Data Pipeline?
AWS Data Pipeline is a web service that you can use to automate the movement and transformation of data.
With AWS Data Pipeline, you can define data-driven workflows, so that tasks can be dependent on the successful completion of previous tasks.



Question: What is Amazon Machine Images (AMI)?
An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud.


Monday, 16 July 2018

How to do SVN checkout in New EC2 instance

How to do SVN checkout in New EC2 instance


Step 1: Login to SSH

Login to Ec2 instance using public DNS (like ec2-54-173-191-129.compute-1.amazonaws.com)
For example:
ssh -i "arunkg.pem" ec2-user@ec2-54-173-191-129.compute-1.amazonaws.com



Step 2: Install the SVN

First you need to install the svn in EC2 instance.
sudo yum install mod_dav_svn subversion


(It will prompt to download the more data from internet, need to say yes)
Step 2: Do the SVN checkout
sudo svn checkout https://subversion.assembla.com/svn/mycityinfo/ mycity

here mycity is folder where all the files will download.


Step 2: Prompt the password for root
When it will promot for the root password, just press the enter key.


Step 3: Prompt the username/password of svn

You need to suply the username and password for assembla.com OR SVN.


Sunday, 15 July 2018

How to create a new user to EC2 Instance in AWS?

How to create a new user to EC2 Instance in AWS?

Step 1: Login to SSH
Login to Ec2 instance using public DNS (like ec2-54-173-191-129.compute-1.amazonaws.com)
For example:
ssh -i "arunkg.pem" ec2-user@ec2-54-173-191-129.compute-1.amazonaws.com



Step 2: Use the following adduser command to add the newuser account to the system (with an entry in the /etc/passwd file).
sudo adduser newuser



Step 3:Switch to the new account so that newly created files have the proper ownership.
sudo su - newuser



Step 4 Create a folder and set the permission
mkdir .ssh
chmod 700 .ssh
cd .ssh



Step 5: Create a file named authorized_keys in the .ssh directory and change its file permissions to 600 (only the owner can read or write to the file).
touch authorized_keys
chmod 600 authorized_keys



Step 6: Open the authorized_keys and write public key in this.
vi authorized_keys

Paste the public key for your key pair into the file and save the changes.
For example:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClKsfkNkuSevGj3eYhCe53pcjqP3maAhDFcvBS7O6V
hz2ItxCih+PnDSUaw+WNQn/mZphTk/a/gU8jEzoOWbkM4yxyb/wB96xbiFveSFJuOp/d6RJhJOI0iBXr
lsLnBItntckiJ7FbtxJMXLvvwJryDUilBMTjYtwB+QhYXUMOzce5Pjz5/i8SeJtjnV3iAoG/cQk+0FzZ
qaeJAAHco+CY/5WrUBkrHmFJr6HcXkvJdWPkYQS3xqC0+FmUZofz221CBt5IMucxXPkX4rWi+z7wB3Rb
BQoQzd8v7yeb7OzlPnWOyN0qFU0XA246RA8QFYiCNYwI3f05p6KLxEXAMPLE




Question: How to remove a user?
sudo userdel -r newuser



How to install the Apache web server with PHP in EC2

How to install the Apache web server with PHP in EC2

Step 1: Login to SSH
Login to Ec2 instance using public DNS (like ec2-54-173-191-129.compute-1.amazonaws.com)
For example:
ssh -i "arunkg.pem" ec2-user@ec2-54-173-191-129.compute-1.amazonaws.com


In Window, you can use download putty and then login.
PuTTY does not support the private key format (.pem) generated by Amazon EC2. PuTTY has a tool named PuTTYgen, which can convert keys to the required PuTTY format (.ppk). You must convert your private key into this format (.ppk) before attempting to connect to your instance using PuTTY. (Note: You need to convert )


Step 2: Login as root usr
sudo su


Step 3: Update the server
yum update -y


Step 4: Install Apache, PHP and MySQL
yum install httpd php php-mysql stress -y


Step 5: Write something in index.php
cd /var/www/html //go to html folder
vi index.php //Write someting in index.php


Step 6: Start the service
service httpd start


Friday, 13 July 2018

AWS Tutorial Terminology page 6

AWS Tutorial Terminology page 6

Question: What is Amazon Route 53?
Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service.


Question: What are main functions of Route 53?
  1. Register domain names: Your website needs a name, such as example.com. Route 53 lets you register a name for your website.
  2. Route internet traffic to the resources: Connect the domain with website source code.
  3. Check the health of your resources: Route 53 sends automated requests over the internet to a resource, such as a web server, to verify that it's available .



Question: Elaborate the Working of Route 53?
;
See details


Question: What is Network ACLs?
A network access control list (ACL) is an optional layer of security for your VPC that acts as a firewall for controlling traffic in and out.


Question: What are basics of Network ACLs?
  1. Your VPC automatically comes with a modifiable default network ACL. By default, it allows all inbound and outbound IPv4 traffic and, if applicable, IPv6 traffic.
  2. You can create a custom network ACL and associate it with a subnet. By default, each custom network ACL denies all inbound and outbound traffic until you add rules.
  3. Each subnet in your VPC must be associated with a network ACL. If you don't explicitly associate a subnet with a network ACL, the subnet is automatically associated with the default network ACL
  4. You can associate a network ACL with multiple subnets
  5. A network ACL has separate inbound and outbound rules, and each rule can either allow or deny traffic



Question: What is Amazon EC2 Security Groups?
A security group acts as a virtual firewall that controls the traffic for one or more instances.
When you launch an instance, you associate one or more security groups with the instance. You add rules to each security group that allow traffic to or from its associated instances.


Question: What are difference between security group and network ACL?


  1. Network Access control lists are applicable at the subnet level, so any instance in the subnet with an associated NACL will follow rules of NACL. That's not the case with security groups, security groups has to be assigned explicitly to the instance.
  2. By default your default vpc, will have a default Network Access Control List which would allow all traffic , both inbound and outbound.
  3. NACLs are stateless unlike security groups. Security groups are statefull ,if you add an inbound rule say for port 80, it is automatically allowed out, meaning outbound rule for that particular port need not be explicitly added. But in NACLs you need to provide explicit inbound and outbound rules



Question: Name the several layers of Cloud Computing.?
  1. PaaS: Platform as a Service
  2. IaaS: Infrastructure as a Service
  3. SaaS: Software as a Service



Question: What are the components involved in Amazon Web Services?
Amazon S3 : with this, one can retrieve the key information which are occupied in creating cloud structural design and amount of produced information also can be stored in this component that is the consequence of the key specified.
Amazon SimpleDB : helps in storing the transitional position log and the errands executed by the consumers.
Amazon SQS : this component acts as a mediator between different controllers. Also worn for cushioning requirements those are obtained by the manager of Amazon.
Amazon EC2 instance : helpful to run a large distributed system on the Hadoop cluster. Automatic parallelization and job scheduling can be achieved by this component.


Question: Name the various layers of the cloud architecture?
  1. CC- Cluster Controller
  2. SC- Storage Controller
  3. CLC- Cloud Controller
  4. Walrus
  5. NC- Node Controller



Wednesday, 11 July 2018

Google speech recognition Integration with PHP

Google speech recognition Integration with PHP

Question: What is Speech Recognition?
Google Cloud Speech-to-Text enables developers to convert audio to text by applying powerful neural network models in an easy to use API. The API recognizes 120 languages and variants.


Question: Does it provide Speech Recognition for real-time streaming?
Yes, Its provide for both real-time streaming or pre-recorded audio.


Question: What are the different languages for it provides speech to text?
https://cloud.google.com/speech-to-text/docs/languages


Question: Does it return immediately?
Cloud Speech-to-Text can stream text results, immediately returning text as it’s recognized from streaming audio or as the user is speaking.
For short audio (less than a min), It return results.

For Longer audio, Its take time (1min -20) depend on audio file length.


Question: What are different Models for Speech to Text?
  1. command_and_search: Best for short queries such as voice commands or voice search.
  2. phone_call: Best for audio that originated from a phone call .
  3. video: Best for audio that originated from video or includes multiple speakers
  4. default: Best for audio that is not one of the specific audio models.

You can set model in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('model'=>'video')
); 



Question: What are the pricing for speech to text?
https://cloud.google.com/speech-to-text/pricing



Question: How to set private key in the environment?
putenv('GOOGLE_APPLICATION_CREDENTIALS=priviate_key_json.json'); 



Question: How to get punctuation in results?
punctuation are the character which we use in written. for example comma(,), perios(.), question mark?.
You can get the punctuation in transcription results by providing enableWordTimeOffsets=true in the config.

for example:
You can set enableWordTimeOffsets in following way
$operation = $speech->beginRecognizeOperation(
   'gs://product_id/file_name.wav',
    array('enableWordTimeOffsets'=>true,'model'=>'video')
); 



Question: What is office link for speech to text?
https://cloud.google.com/speech-to-text/


Question: What is Github link for speech to text?
https://github.com/GoogleCloudPlatform/google-cloud-php-speech


Question: How to install the SDK for speech to text?
php composer.phar require google/cloud-speech



Question: How to get the transcription for small audio file.?
$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);

// Recognize the speech in an audio file.
$results = $speech->recognize(
   $audioFilePath,
);

foreach ($results as $result) {
    echo $result->topAlternative()['transcript'] . "\n";
}   



Question: How to get the transcription for heavy audio file.?
for heavy files, make sure you have already uploaded to google cloud and you have path.

$audioFilePath='gs://ar10w12018/1135-19114_720p.wav';//You can place your path here
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);

// Recognize the speech in an audio file.
$operation = $speech->beginRecognizeOperation(
   $audioFilePath,
    array('enableWordTimeOffsets'=>true,'model'=>'video')
); 
echo $operation->name(); //operation name

You can get the results by using Operation Name.
$operationName='194790781308823479';
$speech = new SpeechClient([
    'languageCode' => 'en-US'
]);
$operation = $speech->operation($operationName);

$isComplete = $operation->isComplete();
if($isComplete){
$results=$operation->results();
}



Monday, 9 July 2018

How to upload files to Google Cloud with PHP?

How to upload files to Google Cloud with PHP?

Question: What are different ways to access Google Services?
  1. Using Client Libraries like PHP, Node, Java etc
  2. Using Gcloud tool command line tool, in this you need to download the cloud SDK which is available for windows, mac and linux.
  3. Using existing command line, similar to above 2nd point.



Question: Question: How to start with client libraries?
  1. Set up a "GCP Console project" (Skip, if already done).
    https://cloud.google.com/resource-manager/docs/creating-managing-projects
    Create or select a project.
    Enable the Google Speech-to-Text API for that project.
    Create a service account.
    Download a private key as JSON (Important, we need this).
  2. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the private key JSON file that contains your service account key(which you have downloaded)
  3. Install the client library



Question: What is price cost for storage?
https://cloud.google.com/storage/pricing-summary/


Question: What are the use cases for storage?
  1. Media storage for website
  2. Streaming videos and music
  3. Mobile app development
  4. Video transcoding
  5. General data analytics and compute
  6. Storage data for Machine learning
  7. Backup data



Question: What are the use cases for storage?
  1. Multi-Regional: For highest availability of frequently accessed data
  2. Regional: For data accessed frequently within a region (cheaper)
  3. Nearline: data which access once a month (more cheaper)
  4. Coldline: data which accessed once a year (cheapest)



Question: What is price cost for storage?
https://cloud.google.com/storage/pricing-summary/


Question: Who are the Partners of Google storage?
https://cloud.google.com/storage/partners/


Question: How to setup of Google storage for PHP?
Step 1 Go to folder where you want to install

Step 2 Install composer (Skip if already)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"


Step 3: Install the library
php composer.phar require google/cloud-storage



Question: How to create folder in Google cloud?
require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;

#Setup the Private Key JSON File in Environment
$credentialFilePath='private_key_JSON_file.json;
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$credentialFilePath);

# Your Google Cloud Platform project ID
$projectId = 'projectName';

# Instantiates a client
$storage = new StorageClient([
    'projectId' => $projectId
]);

# The name for the new bucket
$bucketName = 'mynew-test-bucket';

# Creates the new bucket
$bucket = $storage->createBucket($bucketName);

Question: How to upload file in Google cloud folder?

require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;

#Setup the Private Key JSON File in Environment
$credentialFilePath='private_key_JSON_file.json;
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$credentialFilePath);

# Your Google Cloud Platform project ID
$projectId = 'projectName';

$storage = new StorageClient();
$bucket = $storage->bucket($projectId);

# Upload a file to the bucket.
$bucket->upload(
    fopen('/downloaded/file.mp3','r')
); 



Question: How to delete file from Google cloud folder?

require_once 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;

#Setup the Private Key JSON File in Environment
$credentialFilePath='private_key_JSON_file.json;
putenv('GOOGLE_APPLICATION_CREDENTIALS='.$credentialFilePath);

# Your Google Cloud Platform project ID
$projectId = 'projectName';

$storage = new StorageClient();
$bucket = $storage->bucket($projectId);

$object = $bucket->object($sourceFile); 
$object->delete(); 



Question: What is office link for gcloud storage?
https://cloud.google.com/storage/


Question: What is Github link for gcloud storage (with PHP)?
https://github.com/GoogleCloudPlatform/google-cloud-php


Friday, 6 July 2018

How to convert mp4 to mp3 and wav using PHP FFMPEG

How to convert mp4 to mp3 and wav using PHP FFMPEG


Question: Download the php-ffmpeg library (If not downloaded)?
composer require php-ffmpeg/php-ffmpeg


Question: How to convert Mp4 to wav using php-ffmpeg?
require_once 'ffmpeglib/vendor/autoload.php'; 
$ffmpeg = FFMpeg\FFMpeg::create();
$format = new FFMpeg\Format\Audio\Wav();        
$videoFolderPath='folder';

$audioObj = $ffmpeg->open($videoFolderPath.'/myfile.mp4');    
$audioObj->save($format, $videoFolderPath.'/myfile.wav');




Question: How to convert Mp4 to mp3 using php-ffmpeg?
require_once 'ffmpeglib/vendor/autoload.php'; 
$ffmpeg = FFMpeg\FFMpeg::create();
$mp3Format = new FFMpeg\Format\Audio\Mp3(); 
$videoFolderPath='folder';


$audioObj = $ffmpeg->open($videoFolderPath.'/myfile.mp4');    
$audioObj->save($mp3Format, $videoFolderPath.'/myfile.mp3');



Thursday, 5 July 2018

AWS Tutorial Terminology page 5

AWS Tutorial Terminology page 5

Question: What is difference between stored volumes vs cached volumes?
Volume gateway provides an iSCSI target, which enables you to create volumes and mount them as iSCSI devices from your on-premises or EC2 application servers. The volume gateway runs in either a cached or stored mode.


In the cached mode, your primary data is written to S3, while retaining your frequently accessed data locally in a cache for low-latency access.

In the stored mode, your primary data is stored locally and your entire dataset is available for low-latency access while asynchronously backed up to AWS.


Question: What is VPC flow logs?
VPC Flow Logs is a feature that enables you to capture information about the IP traffic going to and from network interfaces in your VPC.


Question: Where VPC flow logs are stored?
Flow log data is stored using Amazon CloudWatch Logs.


Question: What does do VPC flow logs?
to troubleshoot why specific traffic is not reaching an instance, which in turn helps you diagnose overly restrictive security group rules.
You can also use flow logs as a security tool to monitor the traffic that is reaching your instance.


Question: What are five pillars of AWS Well-Architected?
  1. Security
  2. Reliability
  3. Performance
  4. Cost optimization
  5. Performance Excellence



Question: What is Placement Group?
Placement Group is a logical grouping of instances within a single Availability Zone (AZ) that enables applications to participate in a low-latency, 10 Gbps network. You create a placement group first, and then you can launch instances in the placement group.

Question: What is CNAME record?
CNAME record is a type of DNS record that maps an alias name. CNAME records are typically used to map a subdomain such as www or mail to the domain hosting that subdomain's content.


Question: What is Alias record?
An ALIAS record is a virtual record that we create to provide CNAME-like behavior on apex domains.
For example, if your domain is example.com and you want it to point to a myapp.herokuapp.com, then you cannot use a CNAME record, but you can use an ALIAS record.


Question: What is difference between CNAME Records and Alias Records?
Route 53 charges for CNAME queries whereas does not charge for Alias Records.


Question: What is difference between aws Scale up vs scale out?
Scaling up: when you change the instance types within your Auto Scaling Group to a higher type (for example, changing an instance from a m4.large to a m4.xlarge), scaling down is to do the reverse.
Scaling out: is when you add more instances to your Auto Scaling Group and scaling in is when you reduce the number of instances in your Auto Scaling Group.


Question: What is Amazon Kinesis Data Streams?
Amazon Kinesis Data Streams enables you to build custom applications that process or analyze streaming data for specialized needs.


Question: What is AWS Direct Connect?
AWS Direct Connect makes it easy to establish a dedicated network connection from your premises to AWS.