Skip to main content

Posts

Showing posts from September, 2016

Redirect web url to a specific directory using apache

As i am a developer, i have many scenarios where many project will be in a single server but we have different web url. So we need to redirect the http control to a specific project directory based on our web url.

          For example, example.com code is located in  /var/www/html/home while sub.example.com code at /var/www/html/sub directory. This can be done using apache in ubuntu.

Execute below commands to redirect redirect sub.example.com to respective directory.

cd /etc/apache2/sites-available
Now create a conf file named with your url, for example sub.example.conf and add below code to that file,

<VirtualHost *:80>
ServerName sub.example.com
DocumentRoot /var/www/html/sub
<Directory /var/www/html/sub>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost> Save this file and execute below commands sudo a2ensite sub.example.conf
sudo a2enmod rewrite
s…

Build List on scroll - Jquery

Now a days, we have many websites including social networking and commercial sites dynamically building the list based on our scroll. Here i am showing how to build list based on our scrolling in a whole div and on a specific div.


First of all, we need to write a server side script to give front-end required list. In my example, i am creating ajax.php


<?php $image_path = "images"; $details    = array(     array(         "Amazon",         $image_path . "/amazon.png"     ),     array(         "Apple",         $image_path . "/apple.png"     ),     array(         "Cisco",         $image_path . "/cisco.png"     ),     array(         "Ebay",         $image_path . "/ebay.png"     ),     array(         "Ericsson",         $image_path . "/ericsson.png"     ),     array(         "Facebook",         $image_path . "/facebook.png"     ),     array(         "…

Preview Image before Upload

In this blog, i will be showing how to display selected images to upload before upload in your browser.


First of all, we should have input fields of type file to select images from our drives.


<label>Single File:</label>
<input type="file" id="fileSingle" name="fileSingle" />
<label>Multiple Files:</label>
<input type="file" id="fileMultiple" name="fileMultiple[]" multiple />


<span id="outputSingle"></span> // span to display single selected image
<span id="outputMultiple"></span> // span to display multiple selected images.


Now we should add two event listener to get event 'change' for these two fields.


<script>     $(document).ready(function() {         var multifilediv = document.getElementById('fileMultiple');         if (multifilediv) {             multifilediv.addEventListener('change', MultipleFilehandler, false);     …

Twilio - Record a complete incoming call

Currently, Twilio services does not provide to record the whole incoming call. Only dial initiated within the incoming call can be recorded. But in day to day life, there are many occasion we need to record the whole incoming call such as an ivr call or a customer service call. So, by taking the twilio feature that child call can be recorded, i have developed a call flow using two twilio numbers so that we can record the complete call from caller.
For demonstrating, i have created a small ivr. When caller calls twilio number. It will be asked a gather "whether he/she is interested in taking to our agent? if yes press one or not press two or just hangup". If caller press one, call will be redirected to an agent.

If we try above call method, we get only the recording of agent call. We misses what happened after twilio answer and before agent call. So to get whole call recording, i have developed another mechanism as below

When caller calls twilio number A, twilio will ans…