Saturday, January 10, 2015

vim config

set shiftwidth=4
set softtabstop=4
set autoindent
set tabstop=4
set smartinde

Wednesday, August 20, 2014

Video is not streaming in Safari and Iphone

This may happen due to

RequestHeader unset Range
Header unset Accept-Ranges

>>Why do we need above configuration?
We do this to fix "Range header DoS vulnerability Apache HTTPD 1.3/2.x" issue. For details please check @

>>Does iPhone/iPad Safari require 'Accept-Ranges' header for video?
Yes. It requires these headers.Please find the apple documentation for the same.

>>Any other solution?
Actually we can use another fix as suggested @ . It is as below.

SetEnvIf Range (,.*?){5,} bad-range=1
RequestHeader unset Range env=bad-range

Here we are rejecting request when more than 5 ranges. But we can put very high value too.Please check these lines in same document.

The number 5 is arbitrary. Several 10's should not be an issue and may be
required for sites which for example serve PDFs to very high end eReaders
or use things such complex http based video streaming.

We will enable "Accept-Ranges" at .htaccess file for .mp4 videos only as below.


Header set Accept-Ranges bytes


other ffmpeg help link-

Issue 1: Audio was not playing
Cause: Sample rate of the audio file did not match with the sample rate of the video.
Check videos sample rate-- ffmpeg -i video.mp4
Use the flag -ar to specify Sample rate of audio.

Issue 2: Video was not streaming.
~~~~~: Video should be "Progressive" in nature. Video should provides its meta info at the beginning so that it playback as soon as possible.
Use the following command:

qt-faststart output.mp4 output1.mp4


Final commands:
1) ffmpeg -i video.mp4 -i test.mp3 -vcodec copy -acodec aac -strict experimental -shortest output.mp4
2) qt-faststart output.mp4 output1.mp4

Wednesday, May 14, 2014

How to enable old closing position in Vim

Please add below lines in Vimrc

if has("autocmd")
   au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
         \| exe "normal! g'\"" | endif

Saturday, March 29, 2014

virtualBox ERROR - Kernel driver not installed (rc = -1908)

1.This command will display modules of virtualbox
#cat /etc/sysconfig/modules/VirtualBox.modules
2.Now  i want fix this problem using ‘systemd-modules-load.service’.insert this in “virtualbox.conf”
## vi /usr/lib/modules-load.d/virtualbox.conf
#Loading VirtualBox modules
and restart service
# systemctl restart systemd-modules-load.service # systemctl status systemd-modules-load.service
finally reboot and it will work fine. without any error!!!

Saturday, February 15, 2014

Stack Implementation using Linked List

using namespace std;

//class for each node of stack
class Node{
        Node* nextNode;
        string data;
        friend class Stack;

//Stack Class
class Stack {
        Node* top;

        Stack() {
            top = NULL;
        int push(string data);
        string pop();
        int traverse();

//push operation - insertion at top
int Stack::push(string data) {
    Node* temptr = new Node();
    temptr->data = data;
    //if not adding first node
    if(top != NULL) {
        temptr->nextNode = top;
    } else {
        temptr->nextNode = NULL;
    top = temptr;
    return 0;

//pop operation -- deletion from top
string Stack::pop() {
    string data = top->data;
    Node* temptr = top;
    top = top->nextNode;
    return data;

//traverse the stack elements
int Stack::traverse() {
    Node* temptr = top;
    while(temptr != NULL){
        cout<< temptr->data <<endl;
        temptr = temptr->nextNode;
    return 0;

int main() {
    Stack* so = new Stack();
    cout<<"Display Stack::\t"<<endl;
    cout<<"Popped Item::\t"<<so->pop()<<endl;
    cout<<"Display Stack::\t"<<endl;

Monday, January 13, 2014

Send HTML mail with embedded Image using Javamail API

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class Testmail
   public static void main(String [] args)
      // Recipient's email ID needs to be mentioned.
      String to = "";
      //String to = "";
      //String to = "";

      // Sender's email ID
      String from = "";

      // sending email from localhost
      String host = "localhost";

      // Get system properties
      Properties properties = System.getProperties();

      // Setup mail server   ""
      properties.setProperty("", host);

      // Get the default Session object.
      Session session = Session.getDefaultInstance(properties);

         // Create a default MimeMessage object.
         MimeMessage message = new MimeMessage(session);

//Create multipart message
MimeMultipart multipart = new MimeMultipart("related");

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
                                  new InternetAddress(to));

         // Set Subject: header field
         message.setSubject("This is my Subject");

         //add text part
BodyPart bodyPart = new MimeBodyPart();
         String htmlText = "<html><body><img src='cid:myimageid' /><p>this is my html body</p></body></html>";
bodyPart.setContent(htmlText, "text/html");

//add image part
MimeBodyPart imagePart = new MimeBodyPart();
imagePart.setDataHandler(new DataHandler(new FileDataSource("/home/gauravp/mail/NSAwarnsofpowergridshutdown.jpg")));

         // Send message

         System.out.println("Sent message successfully....");
      }catch (Exception e) {

Saturday, October 26, 2013

Setup Hadoop 2.x (2.2.0) on Linux (Fedora19)

Prerequisite -

1- install Java (openjdk-7-jdk or oracle-jdk-7)
2- install openssh-server

Hadoop Installation Process

1- Add Hadoop Group and User
$ groupadd hadoop
$ useradd hduser -g hadoop
$ passwd hduser

2- After user is created, login using hduser and Setup SSH Certificate
$ ssh-keygen -t rsa -P 'some_text'

$ cat ~/.ssh/ >> ~/.ssh/authorized_keys
$ ssh localhost

3- Download hadoop 2.2and extract
$ wget
$ tar xvfz hadoop-2.2.0.tar.gz

4- Setup Hadoop Environment Variables
$ vi ~/.bashrc
and add below lines at the end of the file.

#Hadoop variables
export JAVA_HOME=/soft_install/jdk1.7.0_05/
export HADOOP_INSTALL=/home/hduser/hadoop-2.2.0
###end of paste

$ cd /home/hduser/hadoop-2.2.0
$ vi

create file by adding below lines.

#modify JAVA_HOME
export JAVA_HOME= /soft_install/jdk1.7.0_05/
$ . ~/.bashrc

$ hadoop version
Hadoop 2.2.0
Subversion -r 1529768
Compiled by hortonmu on 2013-10-07T06:28Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
This command was run using /home/hduser/hadoop-2.2.0/share/hadoop/common/hadoop-common-2.2.0.jar

Congratulation..! hadoop is installed.

Post-Installation Configuration for Hadoop

$ cd /home/hduser/hadoop-2.2.0/etc/hadoop
$ vi core-site.xml
#Paste following between <configuration>


$ vi yarn-site.xml

#Paste following between <configuration>


$ cp mapred-site.xml.template mapred-site.xml

$ vi mapred-site.xml
#Paste following between <configuration>


$ cd ~
$ mkdir -p mydata/hdfs/namdnode
$ mkdir -p mydata/hdfs/datanode
$ cd /home/hduser/hadoop-2.2.0/etc/hadoop
$ vi hdfs-site.xml

Paste following between <configuration> tag


Format Namenode
$ hdfs namenode -format

Start Hadoop Service
$ jps
If everything successful then you will get following services.
8379 DataNode
9097 NodeManager
8805 ResourceManager
8202 NameNode
9253 Jps
8599 SecondaryNameNode