Saturday, April 15, 2017

Graduate From WhatsApp University

Strange title, right? Since WhatsApp was launched, it has phenomenal number of users. I should say people are addicted to it now. After WhatsApp many other messenger apps came and went but it could not affect WhatsApp. WhatsApp users were never decreased and it's increasing year by year. That is good, everyone should be connected to social world through technology and WhatsApp is doing phenomenal job in connecting people with features like chats, voice calls, video calls and groups it's allowing users to stay in touch with others. On WhatsApp daily billions of messages are sent and received.  If there is a breaking news it can go viral in matter of minutes in WhatsApp. But here question is are all those messages and facts exchanged over WhatsApp true? At what level we should trust the information on WhatsApp? 

Unfortunately the situation right now is everyone trust WhatsApp information blindly. They don't go in depth of information. They don't even try to verify it twice before assuming it to be correct. That's why I gave title to this post as 

"Graduate From WhatsApp University" 

I have seen this lot of time. Everyone believes that if it's on WhatsApp, it's true. Many of them show off their knowledge because they read it on WhatsApp and even when you ask for proof, they say it's on WhatsApp, isn't it enough?

No it's not enough, WhatsApp is not reliable source of fact of information. Sometimes it's true that informations on WhatsApp are correct but not every time. WhatsApp is the source used to mis lead the people and it's also a source to circulate propaganda and unfortunately this propaganda becomes fact as soon as it's over WhatsApp and every one believe it. 

So if you are addicted to WhatsApp, please make sure you don't become "Graduate From WhatsApp University" All the information on WhatsApp are not correct. Think twice before you believe it and forward it to someone else. It may create panic among users and you may become victim of fraud. For example, read one of my blog here on how fraud information are circulated on WhatApp and how you can be safe from it.

I am not denying that, WhatsApp is source of knowledge and information. People share information on their fields and as well as other fields. But they don't check about facts of information of other fields. As soon as you got some information, you just forward it to others and it became viral. So it's possible that some information might be mis leading or wrong but since it is on WhatsApp it become fact. 

Take my example, I am a computer engineer but if I show off my knowledge of economics by reading it from WhatsApp, I will be a Graduate of Economics from WhatsApp University. But I don't want to be that and that's why I published this post.

So moral of the story is don't be a Graduate From WhatsApp University. First of all check for the facts and see if information is correct or not and then forward it to someone else and show off it to someone else.

Tuesday, April 4, 2017

Chatbots should be Smarter

Recently I published a blog on Why business will need a chat bot. You can read it here.

Why Each Business Will Need A Chat bot

In that blog I mentioned that this bots need to be very very smart to interact with humans. The algorithms should be powerful to have conversation with humans because humans will do every possible tricks to trap bots and sometime it fails. Survival of fittest, rule of Darwin is applicable to AI as well. Only strong and intelligent algorithm will survive. If you are creating bot make sure you make it really smart, then only it will survive.

Lets start blog by one incident I recently had with bots. I was working with Amazon AWS and faced some issue in it and solved it my self so as per my practice I immediately published a blog and published on twitter. Following is my tweet.

And I got reply from AWS twitter bot.

Technically bot is not wrong as I mentioned word "not working" in my tweet but that was my blog title but it understood as an issue and replied with suggestion so it's not complete fail but as I mentioned bots need to be smart enough to identify what exactly customer needs and reply to it.

Along with Artificial Intelligence a chat bot needs Emotional Intelligence (EI) to understand human emotions. As we move into the future, AI needs humanizing qualities to improve the way it interacts with us, meets our needs for information, and even controls the other technology around us. As AI becomes more ubiquitous, society needs chat bots to become emotionally intelligent if they are to be used to their full capabilities. Humanizing the chat bot is the next step toward a more connected and integrated future. Blending technology with human capabilities such as emotion and empathy can revolutionize the workplace and other facets of life. In my opinion, smarter AI is one of the most exciting prospects of the future.

Monday, April 3, 2017

Tips for Better Audio Recording


This is again bit different blog than programming. Recently I worked on a video course for Packt Publishing. You can find more details on it from following link.

Beginning Laravel

This is video course where I have to speak and work on computer and my computer screen and audio will be recorded to create the course.  Packt Publishing team gave me good tips and suggestions for audio recording. In this blog I am going to explain some more tips which I used while recording and that really helped me lot.

Tip 1 : Prepare a script and stick it in front of you

When you are doing work on computer and at the same time you have to explain what you are doing. It may be possible that you may lost the flow and you forgot on what to speak. So to avoid this, it's better, you write down everything from beginning to end and put it on paper and stick that paper in front of you while you are recording so either you can simply read from it or in case when you forget something and confused in what you have to speak, you can look into the paper in front of you and start reading from it. If you can stick each single paper in front of you that will be good. This way you don't have to flip paper as flipping paper will also make some sound and that may spoil your recording. For one of the video which I recorded, the script was of six pages and I set each paper in front of me on cardboard so I can easily read it. You can either type the script and take print out or it can be hand written but make sure you have good hand writing so you don't have any difficulty in reading it.

Tip 2: Record after mid night

For audio recording, you need a quite place. Best place is recording studio but you can afford it for small course so either have do it at home or some other quite place. But at every place there is some disturbance of out side sounds. For example I tried a weekend home but it was remote place and there were lots of bird around it so there was constant sound of tweeting. My office is near to highway so there is constant sound of vehicle passing by.  So best time for the recording is at mid night at home around 3:00 AM in night. At this time you will not have any disturbance as people around are sleeping and there is no vehicles coming and even birds are sleeping so there will be a quite atmosphere and you can record everything easily.

Tip 3 : Practice it couple of times before final recording

As a programmer I can write code easily as nobody is watching my screen so if I make any mistake that will be fine. But recording the screen is different scenario. If you make a mistake you may have to redo everything again so it's better to have some practice before you go for final recording. Practice entire flow couple of times so that you will have good confidence. So when you go for final recording, you can easily do it without any issue as you had a good practice of it and you don't have much retake of your recording. 

Beginning Laravel Video Course

Here is something unusual I did apart from programming. My first ever video course "Beginning Laravel" with Packt Publishing

In this course you will learn about basics of Laravel Development. First section is about installation of Laravel. This section will start with introduction of Laravel and installation of Laravel in Mac, Windows and Linux. Then we will cover, basics of Laravel including, understanding of Framework Structure, basics of Artisan Commands, Composer, Core Concepts of Laravel, MVC structure, Database Migrations, Laravel Controllers, Models and Views etc. In last section
We will finish this course by creating simple Web application with Laravel which will have CRUD operations and basic validations in final section, this will help you getting started with Laravel Development. If you are interested in learning Laravel then this is the course you are looking for. You can buy it at following link.

Beginning Laravel Video Course

Hope you will like this course. Let me know your feedback in comments.

Thursday, March 30, 2017

PHP Debugging - Look for Case Sensitivity In Variable, File Names and Class Names

This blog is coming out of conversation with one of the developer in my team. He recently made some changes in API in local development and push code to test server. But on server it was throwing an error and API was not working. So after trying hard for sometime he came to me and asked for help. He showed me lines of code he has added and as an experienced person I immediately caught his error. The problem was, he declared variable in lowercase and was using variable with uppercase in next line and that's what breaking on server. Something like this

$var = new Class();
$VAR->prop = value;

Case sensitivity is one of the major reason for errors while you are working on local development environment with XAMPP, WAMP in Windows. At this time case sensitive is not applied and it will  treat


as one and the same variables. But when you are working on server, you have unix / linux operating systems like Ubuntu, Fedora etc. At this time case sensitivity is applied and


Are treated as three different variables. So by mistake if you declare it with lower case and try to use it upper case, it will give you an error. So if you are facing this issue that, code works on your local machine, but does not work on server look for the case sensitivity.

Same goes for the filenames and class names. If you have adde file with name


and if you include it with

include 'MyClass.php';
require 'MyClass.php';

Then it will not be able to find file and it will throw warning or fatal error if you are using require. So make sure that you maintain case sensitivity while naming your class, variables and files in PHP because ultimately your code will be pushed to UNIX / LINUX server and it is case sensitive. 

Thursday, March 16, 2017

Why Your Business Needs A Chat bot

Recently we have been discussing to add a chatbot for our new venture and that lead me to write this article on why a business will need a chatbot and what are the advantages of it.

What is a Chat bot?

In a very simple definition, a chat bot is a computer program designed to simulate conversation with human users, especially over the Internet.

So yes a chat bot is nothing but a computer program which can handle communication with users over the internet using the smart and artificial intelligence programmed in it by the developers. So in a way chat bot is your virtual customer care executive which does not exits in real life but it's in computer. Many of the businesses and website have real time talk to customer care on their website. You start a chat and in few moments you got a reply from one of the executive. But may times it's not human it's bot replying to your queries and helping you in finding a solutions to your problem. It talks like human, it behaves like human and it lead conversions like human but the fact is it's chat bot program which is replying to you. Many of the businesses are using the chat bots successfully and many of the companies are developing chat bots. Real challenge right now in chat bot development is that you have to make it really really smart to handle all types of conversation and with the increasing use of Artificial intelligence, machine learning and deep learning, natural language processing chat bots are becoming smarter and smarter. Even smarter than human as well. 

One of the biggest trends in social media, specially social messaging apps, are bots and bot stores. Technology analysts predicted that bot stores will be the biggest thing since the rise of app stores. in 2017 we will see many developments on chat bots. Most of the businesses will opt for chat bot services to improve their business practices and customer care. Here are some reasons on Why Your Business Needs a Chat Bot

1) 24 X 7 Customer care

Computer do not eat, computer do not sleep, it needs only constant power to be on for 24 X 7 hours. So if you are using chat bot for the customer care, your customers will get 24 X 7 hours services. They can contact you any time and your bot will reply to them on behalf of you. This way your customer will be much satisfied and you can attend customers queries across the globe and different time zones. You don't need a call center and team of executives to handle it and it's cost effective too as you don't have to pay salary to customer care executives and do not need to invest in customer care center infrastructure, just invest in a chat bot and it will work for you all the time.

2) Better Customer Engagements with Buying Influence

Most of the companies selling online their services and products are using chat bots customer engagement. A customer browsing through your websites, products and services online on your website and chat bot can give more options to your customers based on customer preference and it will be more interactive experience to your customers and users as they feel it as a very personalized approach and they will be happy with this and you will get better customer engagements with this. Also chat bot can ask for the user preferences like what style they want and what brand they want and based on that, it will suggest the buying options thus influencing customer with more buying options.

3) Boost Social Media Engagement

In April, Facebook announced it would be opening up its increasingly influential Messenger platform in beta — and allowing brands to start using chatbots there. Not only can this help brands to achieve better sales, but it’s also a natural way with which to bolster social media engagement. By deploying a useful chatbot on Facebook, you’ll be far more likely to attract users on to your business page – where you are hopefully already bending over backwards in order to drive sales and engage with consumers on a personal level.

4) Simplify Your Business Processes

A chat bot is not just for the customer care and sales, it can even help you with your businesses. A custom chat bot designed for your business can help you simplify your business processes and let you be more productive in your business. A chat bot can also take business decisions based on certain parameters and help you in maintaining flow of your business.

In a way, chat bot is going to take industry by storm in upcoming years and chat bot will act as

  • Your lawyer
  • Your personal stylist
  • Your personal assistant
  • Your doctor
  • Your financial advisor
  • Your teacher
  • Your Accountant

and many more you can imagine.

Saturday, March 11, 2017

5 Best Examples of Internet of Things in Real Life

What is the Internet of Things?

Now a days we hear lot about this phrase, Internet of Things or IOT. The IoT refers to the connection of devices other than typical fare such as computers and smartphones to the Internet. So any device other which is able to communicate with Internet can be referred as IOT. So your smart car, wearable devices like heart monitors, your kitchen appliances or your smart TV can be considered as IOT as it's able to communicate with internet for different purposes. So a network of internet-connected objects able to collect and exchange data using embedded sensors and any stand-alone internet-connected device that can be monitored and/or controlled from a remote location is considered as Internet of Things. IOT is really growing in market. HP did a small survey in which they estimated the rise of connected devices over the years and the results are surprising. By 2025 1 trillion devices will be connected to internet. These devices will bridge the gap between physical and digital world to improve the quality and productivity of life, society and industries. 

Here are 5 Best Examples of Internet of Things in Real Life

1) Intelligent Fridge by Samsung

The ‘Family Hub’ refrigerator is equipped with a 21.5 inch HD LCD resolution screen, which allows consumers to use a calendar, post content, pin photos or write your notes. Additionally, you can look inside their fridge at any time with the help of cameras that are embedded in the fridge itself. Lastly, healthcarethe consumer can use the fridge to purchase things online, manage recipes and compile and compare shopping lists. You can read more about it from following link.

2) Apple / Samsung Smart Watch

And the most talked company of gadgets and devices. Apple has changed the world with its inventive and ultra-modern devices. Be it phones, laptops or any other electronic device, Apple has itself strongly established. The Apple watch is the example of how advanced the technology is at Apple. Apart from time and date, the Apple watch enables you to keep a track record of your health and daily activities.  Samsung also have launched the smart watch samsung gear S3 to take on Apple watch. You can read more about this at following links.

3) Philips-Hue Bulbs

Philips hue bulbs have now stepped into a new stage of innovation with these smart bulbs. Linked with your mobile phones, you can now actually control the intensity of lights on your fingertips. The combination of bulb with mobile technology is next thing for your home. Instead of going for different watt of bulbs to suit the mood and the environment, simply change the intensity from dim to medium to full using your phone. You can read more about it from following link.


4) Connected Mascara by L’Oreal

L’oreal is working on interactive cosmetics, able to give its customers a useful how-to content. Imagine your mascara suggests you what type of make-up should you choose to match your outfit. Insane? Actually, it may become part of our everyday reality pretty soon. You can read more about it from following link.

Connected Mascara

5) Mimo Monitors

They have been around for some time now. Mimo Monitors are not only affordable but also presents a new technology. Used for several business purposes, this loT has been making things easier, simpler and is said to be very productive. But now Mimo Monitors offers something unique and unexpected. The technology now enables you get updated to your baby’s body position, their breathing level, body temperature, response to activities and health.  More you can read it following link.

Smart Baby Nursery

It's All About Object Oriented Programming (OOP / OOPS)

Hello and welcome to next post of the series "Freshers to Professional" blog. In case you missed previous blogs, you can read here.

Part 1 : Because All The Leaders Were Developers Once
Part 2 : Some of the Greatest Programmers of All Time
Part 3 : How to be a Good Developer and Professional

Now we will cover some of the basic fundamentals that you should be clear with, when you start your carrier as fresher. In this post we will see about Object Oriented Programming commonly referred as OOP or OOPS.

This is most important fundament of software engineering now a days. When I interview a freshers of the post of the developers, this is my first question to them. "Tell me Three Main Principles of Object Oriented Programming". When someone fails to answer this question, I do not go further in interview and let them go. In my opinion every fresher should know about concepts of OOP. That's the crux of software development. Now a days no matter what language you use, all of them supports OOP. Be it JavaScript, PHP, C# or Java or anything all of them support OOP only implementation if different and if you are clear with fundamentals of OOP then you can implement in any of the languages. As fresher this is what is expected from you and that's why language like C++ and Java is included in almost all the courses of Computer science.

During my tenure in IT industry, I have interviewed many freshers and very few time I get satisfactory answer on concept of OOP. Some freshers knows only the name of concept but they can not explain it further. Some of them can explain it but with great confusion. When I ask them why they don't know about it, they say "We think it's not important" Now that's the biggest mis understanding. OOP is followed in most of the development in business applications. So you should be clear with fundamentals of OOP.

Why OOP was introduced?

Object oriented programming concept was created because of the need to overcome the problems that were found with using structured programming techniques. In earlier days programmers used to write many lines of code because OOP was not there. With the the OOP number of lines of codes is reduced because it makes your code reusable and easy to maintain. Any business application is going to change over the period of time and these changes should be easy to do. With OOP it is possible now. Major frameworks are built on concept of OOP and when you are using that framework, you should be knows how the OOP is used in there. Then only you will be able to work with it. Major software design patterns like MVC also works on OOP.  So no matter what language you use, OOP is involved in it. So it is required that you understand OOP concepts and use it in your work.

Also there are other advantages of OOP

  • Code Reusability
  • OOP  provides a clear modular structure for programs
  • OOP makes it easy to maintain and modify existing code 

Now lets see the three main principles of OOP.

Abstraction / Data Encapsulation / Data Hiding

Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. Implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions commonly called methods.

So for the simple example, when you implement a class and define private members of the class, those members will be accessible only inside of the class. If you want to expose some of the functions and members to outside world, it will be declared as public. Here are some of the key things related to Abstraction / Data Encapsulation

  • Class
  • Abstract Class
  • Static Class
  • Static Methods
  • Modifiers like public, private
  • Constructor
  • Friend Functions

I will not give details about it as there are tons of articles available over the internet.


One of the most important concepts in object-oriented programming is that of inheritance. Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time. When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.

Here are some the key things related to Inheritance.

  • Single Inheritance
  • Multiple Inheritance
  • Multilevel Inheritance
  • Hybrid Inheritance
  • Overriding
  • Modifiers


Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. One function with different parameters is also referred as polymorphism. Polymorphism usually comes to picture when we use inheritance and when we have parent and child class relationship.

Here are some the key things related to Inheritance.

  • Method Overriding
  • Method Overloading

So learn about OOP understand it's principles and other related stuff mentioned above if you want to establish yourself as good developer.

Thursday, March 9, 2017

Top 5 Real Word Examples of Artificial Intelligence

The machines haven't taken over. Not yet at least. However, they are seeping their way into our lives, affecting how we live, work and entertain ourselves. From voice-powered personal assistants like Siri and Google Assistant, to more underlying and fundamental technologies such as behavioral algorithms, suggestive searches and autonomously-powered self-driving vehicles boasting powerful predictive capabilities, here are several examples and applications of artificial intelligence in use today.

1) Siri in iPhones and Google Assistnat in Android

Everyone is familiar with Apple's personal assistant, Siri. She's the friendly voice-activated computer that we interact with on a daily basis. She helps us find information, gives us directions, add events to our calendars, helps us send messages and so on. Siri is a pseudo-intelligent digital personal assistant. She uses machine-learning technology to get smarter and better able to predict and understand our natural-language questions and requests.

To take on Siri Google recently introduced Google Assistant. The same voice operated software like Siri to do things on your android phone . You can ask it anything like to search places, translate between languages, calculate something etc. You can tell it to do the things like setting up reminder, send message, call contact.

2) Tesla

Tesla is quite possibly one of the best cars ever made. Not only for the fact that it's received so many accolades, but because of its predictive capabilities, self-driving features and sheer technological "coolness." Anyone that's into technology and cars needs to own a Tesla, and these vehicles are only getting smarter and smarter thanks to their over-the-air updates.

3) Nest

Nest is the most famous name in Home Automation Technology. Most everyone is familiar with Nest, the learning thermostat that was acquired by Google in January of 2014 for $3.2 billion. The Nest learning thermostat, which, by the way, can now be voice-controlled by Alexa, uses behavioral algorithms to predictively learn from your heating and cooling needs, thus anticipating and adjusting the temperature in your home or office based on your own personal needs, and also now includes a suite of other products such as the Nest cameras.

4) Alexa

Alexa is other famous name in Home automation technology. When Amazon first introduced Alexa, it took much of the world by storm. However, it's usefulness and its uncanny ability to decipher speech from anywhere in the room has made it a revolutionary product that can help us scour the web for information, shop, schedule appointments, set alarms and a million other things, but also help power our smart homes and be a conduit for those that might have limited mobility.

5) Netflix

Netflix provides highly accurate predictive technology based on customer's reactions to films. It analyzes billions of records to suggest films that you might like based on your previous reactions and choices of films. This tech is getting smarter and smarter by the year as the dataset grows. However, the tech's only drawback is that most small-labeled movies go unnoticed while big-named movies grow and balloon on the platform.

Top 5 Real World Examples of Machine Learning

What is Machine Learning?

Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed. Machine learning focuses on the development of computer programs that can change when exposed to new data.  Evolved from the study of pattern recognition and computational learning theory in artificial intelligence, machine learning explores the study and construction of algorithms that can learn from and make predictions on data. The process of machine learning is similar to that of data mining. Both systems search through data to look for patterns. 

Machine learning is now widely used by many software manufactures. Most of the IT companies are now investing in Machine learning. Developers are working on creating complex algorithms to enhance machine learning in systems and provide more intelligence to end users. Here in this blog we will see five real world examples of machine learning.

1) Word prediction and corrections in Office 365 by Microsoft

Just when you thought Google's AI products are the best, Microsoft strikes back with AI in Microsoft Word that blows away Google Docs. The recent version of office 365 has mind blowing machine learning added in word prediction and corrections. It just don't correct it but it will also learn from your way of writing and learns the words which you use frequently. It's really awesome. You can read more about it on following link.

2) Facebook and Machine Learning

Facebook builds its business by learning about its users and packaging their data for advertisers. It then reinvests this money into offering us new, useful functionality – currently video and shopping - which it also uses to learn even more about us. Facebook achieve its goals of providing greater convenience to users, and enabling them to learn more about us. You can read more at following link.

3) JP Moragan Software COIN

The program, called COIN, for Contract Intelligence, does the mind-numbing job of interpreting commercial-loan agreements that, until the project went online in June, consumed 360,000 hours of work each year by lawyers and loan officers. The software reviews documents in seconds. COIN is just the start for the biggest U.S. bank. The firm recently set up technology hubs for teams specializing in big data, robotics and cloud infrastructure to find new sources of revenue, while reducing expenses and risks. Read more at below link.

4) Google's Self Driving Cars

Google's self-driving cars can tour you around the streets of Mountain View, California. Google has mapped 2,000 miles of road. The US road network has 4 million miles of road. Google's team uses machine learning algorithms to create models of other people on the road. Every single mile of driving is logged, and that data fed into computers that classify how different types of objects act in all these different situations. While some driver behavior could be hardcoded in ("When the lights turn green, cars go"), they don't exclusively program that logic, but learn it from actual driver behavior. You can read more about it on following link.

5) Google Maps use Machine Learning to Predict Parking Difficulty

Google Maps now tackles parking problems as well. Google quietly launched a new parking feature for Google Maps on Android across 25 major US cities. If you are in these metro areas, you will now see a red parking sign that indicates limited parking availability to help you plan your trip. The interesting part of this update is that it does not rely on internet-connected parking meters; which often provide incomplete or wrong information due to illegal parkers or those who depart early from their spot. Instead, Google Maps combined crowdsourced data and relatively simple machine learning algorithms to classify parking difficulty. You can read more about it at following link.

Tuesday, March 7, 2017

Mac OSX Set Edit PATH Variable

If you are using MAC OSX for development for say android, Laravel, Sencha , Java, Composer then you must have faced this issue. There are SDKs for this development and it's installed some where in your disk and it has certain executable which you can use on command line. For example to create laravel application on your disk you can go to terminal and go to place where you want to create your application and type following command.

laravel new MyApp

But most of the time you get an error command not found. Same with the other development. So if you are using OSX and get command not found error on your terminal, that means you have to set PATH of that command to your PATH variable in OSX. In this blog I am going to mention how to do this.

$PATH variable is very similar to environment variable on windows. Once you add path of command to $PATH variable, you can execute that command from anywhere in terminal. If you want to see what is current values in your $PATH variable. You can go to terminal and type following command.

echo $PATH

and it will show you current values stored in your path. Easy and best way to set value in $PATH variable is through bash_profile file. On OSX each user will have bash_profile file that has this $PATH variables stored. Here you can append new PATH to your SDK to execute certain command. For that first of all open bash_profile file. Go to terminal and type following command.

nano ~/.bash_profile

It will open your bash_profile file. It will look something like this.

Here go to end of the file and add your new PATH here. For that first of you have to find out absolute path of command on your disk. For example in case of laravel. SDK is stored at path


Same way for your command and SDK you have to find out the exact path and add it $PATH variable. Go to end of the file and add path. For example for laravel.

export PATH=/Users/hirendave/.composer/vendor/bin:$PATH

Here we are just appending new value to existing values. To save this click

control + X

It will show below message.

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?  

Type Y here and hit enter. It will confirm from you to save changes to .bash_profile file. Hit enter again and it will close the file and take you back to terminal. Now close all the terminal and launch it again and type the command it will surely work.

So for all the command you want to use on terminal, you can use this trick to save path in $PATH variable to that can be used from anywhere in terminal.

Monday, March 6, 2017

PHP file_get_contents throws 400 Bad Request Error - Google Geocode API

Recently I was using Google Maps API to geocode address with PHP. There were thousands of addresses in CSV and I have to read it one by one and do geocode it and get lat long and other missing info of the address. So I was using file_get_contents function to fire HTTP request and get output like this.

$geocode = file_get_contents(''.urlencode($records[0]).'&key=API_KEY&sensor=false');
$output = json_decode($geocode);

It worked for few address but for some addresses it throws error.

ErrorException in Controller.php line 535:
file_get_contents(URL): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

That's because some of the addresses in the CSV were not properly formatted and there were some special characters in it as addresses were copied from web pages. But the problem was it's eventually breaking the execution of the script. So to fix it use PHP curl instead of file_get_contents. As it does not throw exception on bad request but it gives you response code and that you can check before you get output. So here is my code.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ''.urlencode($records[0]).'&key=APIKEY&sensor=false');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$geocode = curl_exec($ch);

if(curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200) {
        // convert response
        $output = json_decode($geocode);
if($output->status == 'OK'){


So as you can see on above code, we are using checking CURLINFO_HTTP_CODE, if it's 200 that means HTTP request is successfully executed or in case there is a bad request you can check it and skip accessing the output. So it won't throw an error.

Saturday, February 25, 2017

Best Foods and Strategies for Eating at Your Computer

This is again bit different blog from my side. Till now I have been writing blogs on coding issues and updates and technologies etc but now I have decided to focus on some other areas like tech humor and other things related to computers and programmers. This blog is about foods you can east near your computers and how to have them so that it does not harm your computer. I am sure you don't want to ruin your computer because of some accident while eating near your computer, as shown in the image below.

This type of accident can ruin your computer and data inside it and in turn it can ruin your work. So better to take care about it. I have been working as a software engineer since last 9 years so sometime I don't get enough time to eat so sometimes I eat while I am working near the computer so some of the tips mentioned here are from my own experiences. By the way I never ever had an accident while eating near the computer and ruined my computer.

Tip 1 : Avoid cold drinks if possible or else be careful

As we all know a cup of coffee is must for the programmers and specifically for those who are working late nights. There are even jokes about coffee and programmers like.

Programmer - An organism that converts caffeine into code

So a coffee is must for the programmer but this is the drink that ruins your computer most of the time. Here are some situations

  • You are looking at your code and are so stressed that you don't even know that a drink is spilled on your keyboard. 
  • Sometimes after having a sip when you are putting it back, but you are still looking at your screen an boom, accident can happen. 
  • Sometimes if drink is cold or you just took it out of the fridge, there is a water at outer layer of container and its dropping when you are holding in your hand

So there are many ways a drink can ruin your computer so be careful while using it. As mentioned earlier

  • Look at when you are taking it for a sip and putting it back.
  • Avoid cold drinks and if you are having it make sure you sip it from distance.
  • Keep the cold drinks away from your computer.

Tip 2 : Avoid food with sprinkles or garnishing and sauces

There are foods like potato chips or pea nuts or say cashews which has sprinkles of spices on top of it. When you eat it with your hand, some of the sprinkles will remain in your finger tips and when you touch key board with it, will make your keyboard dirty. Either you have to wipe out the keyboard or wipe out your hand every time and that will not just delay your work but it will also break your concentration so better to avoid this types of food. You can have plain food without any sprinkles on top of it. Also you can avoid foods with sauces as there is possibilities of dropping sauces on keyboard while you are eating it so better to avoid it. Avoid the foods that creates mess around your computer.

Tip 3: If you are having fruits, avoid juicer fruits and cold fruits

Fruits are the best things to eat near the computer because most of the fruits like grapes and bananas you can eat with your hands and there is no possibilities of spilling. However some juicer fruits should be avoided as there may be possibility of spilling of juice on keyboard. At the same time avoid fruits that just came out of refrigerator as that has water coating on surface and it will make your finger tips dirty and eventually will make your keyboard dirty. Do not eat fruits juiciest fruits like water melons, Oranges etc. 

Hope this tips helps you and save your computer.

Laravel: Failed to connect to port 80 on OSX

Recently I was trying to create new Laravel application with Laravel installer, it was not working and it was throwing following error.

Failed to connect to port 80: Operation timed out [url]

I was not sure about error so I tried few things like updating composer and updating laravel installer but still it was not working but finally I was able to solve problem so in this blog I am going to explain how to solve this issue.

This issue is because even after updating laravel installer version with composer it's still using old version of composer which was installed in /usr/local/bin library. To find out this type following command in terminal.

laravel --version

If it shows following output that means you are still using old version of laravel installer.

Laravel Craft version 1.0.0

So to remove this version first of all remove old version. Go to terminal and type following command.

rm /usr/local/bin/laravel

Now will again install laravel with following command.

composer global require "laravel/installer"

It will install laravel in your users home directory, so you have to add path to it in your bash_profile file. Open the bash_profile file for editing.

sudo nano ~/.bash_profile

And copy following line in it.

export PATH=/Users/USERNAME/.composer/vendor/bin:$PATH

In above line replace USERNAME with your OSX username. Save the file and reopen the terminal. Now again type following command.

laravel --version

And it will show following output.

Laravel Installer version 1.3.1

So now you have the latest version of laravel installer, create new laravel application with following command

laravel new app-name

Hope this helps you.

Monday, February 20, 2017

Stop User From Uninstalling Your Mobile App

I have been developing mobile applications since last 5 years and over this period of time I have developed many applications for Android and iOS. These applications includes both native and hybrid applications. In this blog I am going to explain certain important things you should consider while developing mobile app so users won't uninstall after using it. These is based on my own experience of developing mobile applications. You may have other views on this. Let me know your views in comments.

Do not increase size of your mobile application

This is first and foremost factor you have to consider while developing mobile application. Now a days storage is biggest concern in smart phones. You have so much other data like photos, videos, musics etc. So at most of the time you get waring of "Storage space running low" at this time users will uninstall mobiles apps which is taking too much space. So if your mobile application is heavy in size and consume lots of spaces on your mobile phone at one point of time, users will going to uninstall your application so make sure you keep size of your application to some limits. Make sure you store data in SD cards so that your application does not consume much size. Try to clean up storage space from the app so that you do not have unnecessary data.

Real Life Story : Let me give you an example on how we reduced size of mobile app. In one of the app we need to have text to speech function. There is a lesson and user can play audio of that lesson and can hear it. So we decided to use in built text to speech function of android so we don't have to include MP4 files of audios.

Make it efficient to consume less data and battery

People now a days are very conscious about their phones, they can not live without it so they make sure that there is always active data connection and mobile battery is always charged. In this case if your application is consuming too much data and battery and your user has to charge it very often then there is high chance that they will uninstall your application. So make sure if you have functions like background services, GPS , location tracking, you also have strategy to save battery power. Always use power saving strategy. At the same time make sure your application is not using too much network data.

Real life story : We created mobile app to background location tracking. First we were tracking user location each 10 seconds for very accurate tracking but battery of mobile phone was always drained so later we changed location strategy and tracked user location based on considerable movements and at regular time interval of 5 minutes and used network locations as well.

Make sure they understand application

This problem is particularly with business applications where users of mobile app have difficulties in understanding functions of the app. They do not understand the flow and screens of the app and hence they get confused and stop using application. This rate is very high in business app and business app comes with strict requirements and flow as per each business and users have to understand it. To solve this problem you can include tutorials in your mobile application. You can use overlay tutorials on your mobile application screens to point out functions of each buttons and screens so user will know where to tap and what's the flow of the app.

Make sure application is bug free and do not crash often

If your application crashes often and have bugs your user is going to be annoyed with your app and will uninstall your application so make sure your application is bug free and do not crash. Although most of the developers will make their application bug free but still sometimes it happens that your mobile app crashes due to some reasons and no user will like it. So make sure you handle all the errors and exception properly.

Allow user to remove Ads

Well, the ultimate aim of the mobile application is to generate revenue from it and for that most of the users will put ads in the mobile app but sometimes these ads are annoying for end users. Specifically the ads which pop ups suddenly and stops users from doing work with app. Specifically for the games user will not like ads if it is not letting them play games properly so user will uninstall mobile app if you not allow them to remove ads. So yes you can add the ads in mobile app but let user remove it for the session while they are using the application. So they can hide it temporarily and use your app. 

Along with these there are some small tips you can also consider. 

  • Do not annoy user with too much notifications
  • Make UI very fast and responsive
  • Choose color scheme properly
  • Make it responsive to fit in all the screens
  • Do not use big images

If you consider these factors while developing your app user will not uninstall your app. 

Saturday, February 18, 2017

Tech Humor - A Programmer's Revenge, Deal With Frustration At Work

Hello, this is bit different blog post. Usually I write blogs on very serious stuff like solving coding issues and about technologies and careers and about latest trends on IT industries etc. Now I feel that my blog is becoming very serious so I decided to write some blogs on lighter notes. Now you will read about funny things happened while working on projects some practical jokes on programming and all. I short I am going to add bit humor on my blog. In this first post I am going explain how I took revenge on end users of my projects.

A Programmer's Revenge

A programmer is a person who is working all days long in front of computers. He has to deal with all kind of annoying stuff like funny and impractical demands of customers, anger of his boss, anger of tester, humiliation from boss and team leaders or may be from co workers. A programmer deals everyday with these and more of the other things like.

  • Sudden change in requirements
  • Rewrite entire code again
  • Work rejected by client or team leaders
  • Do extra work without any rewards
  • No credit on successful completion
  • Tight deadlines or change in deadlines
  • No help from co workers of leaders
  • No motivation from boss and team leads
So in short a programmer is always in frustration most of the times and eager to take revenge but can't do that as he is afraid of loosing job or cut pay  etc. So here are some funny ways you can take out your frustration and nobody will notice it and still you will have some kind of satisfaction that you took revenge of all the humiliations, frustrations, disappointments etc.

Add Some Funny Comments and Lines in Code

This is the most hidden way to take out your frustration as no one els is going to look at source code except you and your team. Most of the time client is not going to see the source code so they will not read comments. Here are some example of comments I have used while I was working on projects to take out my frustration.

//Function : Name of Function
//Author : Hiren Dave
//Description : Use it at your own risk. Do not come to me crying if it crashes

Exception exp = new Exception("Some idiot entered wrong data");
throw exp;

      //God has given brain to all human but some idiots still enter wrong data so we have to check.
       alert('Invalid Salary.');

//What's in the name? Yes everything is in name. It is necessary.

//I can't take it anymore I am exhausted, will fix it later.

//I just don't know why I am writing this code. It's unnecessary but it's part of my job so doing it.

So yes these are some comments I used over the time to take out my frustrations and took my revenge. You can also try this, it will surely help you to manage with your anger and frustration.

Play Shooting And Fighting Games

This is the other way I took out my frustration. Whenever I am frustrated and angry I play shooting and fighting games and squash the opponents in games to release anger and took my revenge virtually in games. Games really help in this matter as you are just hurting virtual characters in games. Here are some games I play for sometime to take out my frustration.

Whack Your Boss
Desert Rifle
Street Fights

These ways you can took your revenge and can deal with frustrations. Hope this helps you.

Friday, February 17, 2017

Top 3 Tips of Effective Google Search For Developers

This blog post is for the developers who are stuck in some errors and not able to solve it and looking for solutions on Google but not able to find it because they are not searching it properly. So here in this blog I am going to explain some tips which I have been using over the period of time and most of the time I am able to get solution through Google and solve my problem.

Tip 1 : Use Error Codes to Search

Most of the time whenever there is exception or errors, there is an error code displayed in the error stack trace. Use that error code to search on Google and use the ClassName or component name which is throwing this error with type of error. For example Android MediaRecorder. When you are using media recorder there are error codes attached with each action and each stage of MediaRecorder. For example

Android MediaRecorder start failed - 38
Android MediaRecorder start failed - 19

When you search in Google with the error.  Android MediaRecorder start failed - 38, you will get following links.

As you can see in above screenshot there is top links of popular website StackOverFlow where others have posted this question and there will be solution here so your problem is solved.

Another example in windows whenever there is problem with drivers of any hardware it gives code 28 errors. So to search in Google use following

Windows error code 28

And you will get number of blog post to solve this error.

Tip 2 : Use Name of Exception To Search, Do not Copy paste whole stack trace

Whenever there is an exception in program, you will get stack trace where it shows all the classes and files and number of line from where exception is thrown. Do not copy paste that stack track in Google Search. Use first line of Stack trace, which is normally type of exception. For example, in android app is some class is not found at runtime it throws ClassNotFound exception. So to solve that error, search in Google 

Android ClassNotFound "ClassName"

And it will give you relevant links where there will be solution for this. So your error can be solved easily.

Tip 3 : Be Specific for What you Want to Search and Use Keywords

Be as specific as possible in your search query so Google can search relevant links for you. For example, if you want to hide element with JavaScript. If you give search

Hide element

It will give you links with hiding element using CSS and JavaScript and jQuery and Angular and all. But if you want specific result with say jQuery or JavaScript, use that key word in your search result.

Hide element jQuery
Hide element JavaScript

Then it will give you relevant links with exactly what you are looking for. Same way for anything else use key words. For example if you are looking for tutorials to start with. Use search like

Laravel Getting Started
Android quick start
Angular quick start etc. Because most of the bloggers who write blogs on Getting started, they use titles like Getting started, quick start etc. You will get what you want on the first page of Google.

Hope this helps you.

Wednesday, February 15, 2017

Copy Paste - Blessing or Curse for Developers

Let's start this blog by asking a simple question to yourself.

Are you a Copy Paste Developer?

Most of the readers who are reading this post, will answer Yes for this question. We all are copy paste developer at one time. I am also a copy paste developer. I usually copy paste some lines of code from my old projects or from some blog post or from the StackOverFlow. All the developers to that at one point of the time. We do this to save our time and efforts. 

So now the questions are Does copy paste always works? Does it make your code better or worst? So in short it is blessing or curse for developers. 

Well, I would say that if you copy paste and do it wisely and with proper understanding then it's really a blessing for you but if you do it blindly you could end up in disaster. It will introduce so many other bugs in your code and eventually you have to start from scratch. 

What are the Good Things about Copy Paste?

Being a copy paster programmer at some time I would say in most of the cases copy paste is good for the developers. You don't have to rewrite entire code once again. With copy paste and little changes you can solve your problem easily. It saves your time and efforts and can solve your problems easily. 

I would like to share my experience here. When I started working on creating iOS app, I was not having enough knowledge of Objective C and all and still I created a full fledge iOS application with Copy Paste. I was working on application for motivational speaker. The requirement was to create app to list lessons of speaker and when user tap on lessons show details of lesson with videos and picture gallery. So what I did is I found open source application for food recipes. Application was very similar to what I was looking for. First of all list of recipes and then details of recipe. So I copy paste the code with views and controllers and all and instead of recipes, put motivational lessons and bingo the app is created. So here copy paste was blessing for me. I created entire IOS application in a week and with much less efforts.

So copy paste is always blessing for developers but you have to make sure certain things while doing copy paste. 

  • Understand the code which you are copy pasting
  • Modify it as per your coding standards and as per your code logic
  • Check for errors in the code before copy paste
  • Do testing after copy paste
  • Write comments in your code after copy paste

What are the Bad Things about Copy Paste?

Copy Paste could be disaster for your if you just do it blindly and you do not try to understand what you are copy pasting. Everyone copies code from StackOverflow or other forums from time to time. Hopefully, you do it sensibly, using it as a starting point for your own production code — working through what you’ve just pasted in to understand it, experimenting with it, modifying it, making it fit for your purpose rather than just blindly copy-and-pasting random code from the internet. It's possible that code which you are copy pasting may have errors or may have entirely different purpose than yours. So it can cause issues in your code and can break your code. 

So I would say only one thing, understand the code which you are planning to copy paste and then copy paste it. 

So it's up to you to turn copy paste into blessing or curse. If you do it wisely, it will always be blessing and there are very rare chance that it may turn into curse for you.

Sunday, February 12, 2017

Why Artificial Intelligence Is Must In Business Application

In this blog I am going to explain why Artificial Intelligence should be added in Business Applications. These are my own point of views which I felt after working on many business applications for more than 7 years. You may have different point of views or you may want to add more to this list. Feel free to add comments in case if you want to share more on it.

What is Artificial Intelligence?

The theory and development of computer systems able to perform tasks which normally requiring human intelligence, such as visual perception, speech recognition, decision-making, and translation between languages. So by adding Artificial Intelligence you let computer system to take decisions on behalf of you. 

In this blog I am going talk particularly about decision making by AI in your system and why it's required. So lets understand what is decision making in business applications?

Each business application have it's own set of rules for decision making but decision masking simply refers to take decision in systems like 

Shall allow user to do task or not?
If not then who else will do it?
If the input is correctly processed or not? etc. Like I said it depends on business to business. Lets see couple of example of real businesses to get more clarity on it.

1) Lead Management

From your sales department, there are lots of leads coming per day. Decision on whom to assign lead is taken my managers on considering so many factors.

  • A person have worked on similar type of lead in past
  • A person can handle business volume mentioned in lead
  • A lead is in area which covered by a person.
  • A person is free to take a lead etc..
These are the factors considered by manager to assign lead to particular person. So this is what is decision making.

2)  Online Shopping

If you have shopped online in past you may have realized that when you go to same eCommerce site again it will show you similar products which you have bought and will prompt you to buy it. There are many factors considered here.

  • What types if products generally you buy?
  • How many times you buy?
  • In what amount you buy? etc.
So based on above factors, it will recommend you products and you may buy it.

So this is what is decision making normally in business applications there is logic for this type of decision making. They let system users to take decision and this is good but sometimes it creates issues. Following are some factors due to which you must add AI for decision making in your business application. 

1) People are lazy in taking decisions

This is first affecting factor of decision making. People who are using system are sometimes very lazy in taking decision. They don't care about time. The data is on their dashboard but they don't even look at it and this hurts overall productivity of the system so it will be better to have AI to take decisions. We can write code to enforce all the business rules for taking decision and let the system take decision about it. This will be very quick and easy process as the automated system will take decision as soon as there is data. 

2) People want to break the rules in the system.

This is my other observation. People always want to break rules in system some times intentionally or some time un intentionally. They don't care about correctness of data. They completely ignore it sometimes and that's why overall system breaks down so it will be better to AI to auto correct human mistakes. We can enforce law in code so the system can auto correct data. So even people want to break the rules they can not. System will prevent them and thus overall system is saved.

So it's always better to have AI added in business application for decision making so that no one can break your system and overall productivity of system is increased.

How To Fix Code 28 Errors in Windows

Today I was called to fix windows again. There was a problem in connecting to internet in windows PC as drivers were not installed for ethernet controller. So I fixed it. I never liked fixing windows, no programmers likes it. I published blog about this few days back. You can read it from following link.

5 Things Programmers Don't Do or Hate to Do

But anyways, I was called to fix it so I fixed it. In this blog I am going to explain how to solve Code 28 error

The drivers for this device are not installed. (Code 28)

When I checked ethernet device, it was showing above error. So first I tired to update driver by let windows automatically search for it but it did not give any result. Tried updating windows also but it didn't work. So finally I had to do all the process manually. First of all to identify which driver you will need download and install following software.

Driver Easy

This software has vast database of drivers so it can find required driver for you very easily. Install the software and scan your computer with it. It will show you device driver software for it and will download it. If you are luck this software will automatically install it but I was not lucky. I am never lucky when I have to fix the things. So again I have to do manual process. Here are steps. This software will show you folder where it has downloaded device driver so keep that folder open, we will need it in later step.

1) Go to Device Manager from Control Panel and click on Ethernet controller.

2) Click on Update Driver, it will show you following screen

3) Select the second option "Browse my computer for driver software". Once you click on second option, it will show you following screen.

4) Click on Have Disk in above screen and it will show you following screen.

5) Click on Browse and go to folder where Driver Easy has downloaded your device driver. From that folder select .inf file and it will start driver installation.

Once the driver is installed it will show you success message. After that just restart your PC to make sure device driver installed successfully. In my case issue was solved after restart and internet connection was working. Hopefully it will solve your problem as well.

Saturday, February 11, 2017

Effective Way to Create and Save File In Android Application

Hello, in this blog post I am going to explain effective way of creating and saving file in android application. Also will explain what are the general mistakes developer make in creating and saving file and how to prevent it.

Why it is important to have strategy for File create and Save in Android?

Because android file system is very similar to disk based file system and when there is a problem in creating or saving file it throws IOException so your application may crash while it's running and it's not good for professional or business application. So you need a proper strategy to create and save file and you have to add all kind of checks and exception handling for this.

Common mistake by developers on Creating and Save file in Android

Any new developer who is working first time on the file make this mistake. They don't know how to create a file and they do not refer to android developer site and android SDK document. They just search on web and find answers on site like StackOverFlow and copy paste the code. But sometime what happens is the code which they have used was about saving file in SD card and it may be possible that some phones do not have SD card so when the application is running in these phones, it crashes.

Another mistake is, in the code they hard code the path of saving file. Each android version and phone has different way of handling SD card so if you hard code the path it may work in your phone but it does not work in other phone. So here you need some strategy for this and make sure that your code works in all scenarios.  Here are some common things you should consider while creating and saving file.

  1. Decide where you want to store file, in external storage or internal storage.
  2. If storing in internal storage make sure there is space available.
  3. If storing in external storage, first check if there is external storage is available and there is a space.
  4. Make sure you have permission to store files in external storage. 

If you have requirement that file created should only be accessed by your app, you should create it in internal storage in app directory or else you should create it in external storage. Here is the code I have used in one of my app to create file in external storage.

For this you should also have permission mentioned in your android manifest file.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;

private static File getOutputMediaFile(int type){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.

File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(

// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("YOURAPP", "failed to create directory");
return null;

// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
} else if(type == MEDIA_TYPE_VIDEO) {
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"VID_"+ timeStamp + ".3gp");
} else {
return null;
return mediaFile;

As you see in above code, we are first checking if external storage is available or not. If it's not available, you just return null and if it's available, depending on file you want to create, create unique file name with current time stamp. Do not use hard coded file name like myVideo.3gp and it will always overwrite the previously created file.

Now we will use above function to check if we have file created or not in external storage and if not created we will create it in internal storage.

File outputFile = getOutputMediaFile(MEDIA_TYPE_VIDEO);

if(outputFile == null){
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
outputFile = new File(getFilesDir() + "/"  + File.separator +
"VID_"+ timeStamp + ".3gp");
} catch (IOException e) {
Log.d(TAG, "IOException creating file : " + e.getMessage());

As you see in above code we are calling this function to create file of type video and check if it returns null. If it returns null then we are creating file in internal storage. Following line creates file in internal directory.

outputFile = new File(getFilesDir() + "/"  + File.separator +
"VID_"+ timeStamp + ".3gp");

And we have enclosed code try catch block to catch any possible IOException. In case of exception, you should properly display a message to user.