Saturday, January 21, 2017

Xcode 8.2 Simulator Crash When Save Screen Shot - Alternate way to take Screenshot of iPhone simulator

I don't know what went wrong with my Xcode. Recently I was publishing an app in iTunes connect and for that I needed iPhone 7 screen shot. I opened simulator and run and app and tried to capture screenshot with Command + S and it crashed the simulator with following error and screen shot file was empty.

It shows some error related to some library of SwiftFoundation. I was not sure about this error. So first thing what I did is report it to apple and then tried few things like. Restarting simulator couple of times and restarting Xcode couple of times. But it didn't work. So may be it's related to SDK update. I updated the latest SDK but still it was not working. So at last I give it to Apple to solve the problem but I needed that screen shot. So here is alternate way to take Screenshot of iPhone simulator.

With simulator running. Select Go to Edit menu and Select Copy Screen.

This will copy current screen of simulator. Now open the preview and go to File and Select New From Clipboard.

And it will give you new image with copied screen of your simulator, now save it and use it with Preview. Hope this helps you.

Thursday, January 19, 2017

Magento 1.9 Ajax Login with Social Connectors

We are using Magento 1.9 right now for one the project as Magento 2.0 has certain performance issue and some of the extensions are not yet available for Magento 2.0. In this project we have a requirement to add Ajax Login with Social connector options which includes, login with Facebook and Login with Google. Problem we faced is, there is no free extension available in market which allows both ajax login and give you social connector options. So what I did is I installed two different extensions for Ajax Login and Social Connectors and then merged code from social connector plugin to Ajax Login plugin.

In this blog I am going to explain how you can do this.

First of you have to install following two plugins in Magento.

GoMage Social Connector
Ajax Login

With the first login you will get social login options in admin where you can configure your social networks like Facebook and Google and add necessary information like App id and redirect URL etc.

Once it's configured in admin, you will get Social Connectors option in login page like this.

But we need this options in Ajax Login Popup.

So to do this we will copy code for GoMage Extension to this. To do this go to.


And open index.phtml file.

Add following code before buttons code.

<!-- Social Login -->
<a href="#" onclick="gomageSocialFBLogin();return false;" title="<?php echo $this->getText('facebook') ?>">
Login with Facebook

<a href="<?php echo $this->getUrl('gomage_social/google/login', array('_secure' => true, 'gs_url' => Mage::helper('core')->urlEncode(Mage::helper('core/url')->getCurrentUrl())));  ?>" title="<?php echo $this->getText('google') ?>">
Login with Google

That's it and now you will have social connector options in Ajax login.

I have just added basic designs, you can change it as per your requirements.

Wednesday, January 18, 2017

5 Things Programmers Don't Do or Hate to Do

I am a computer programmer and have been working in the IT industry since last 9 years. During this time I have realized many times that a programmer is mis interpreted by many who don't know exactly about programming and IT industry. There are certain myths in mind of non programmer persons that needs to be changed. This blog will explain 5 things that I have heard many times and I really hated to listen that. If you are a non IT person and reading this blog, just make sure next time you don't speak following things in front of computer programmer. If you are an IT person and reading this blog, just enjoy and and add a comment if you want to add something to this list.

Can you Fix my PC? Can you Fix my Windows?

This is the biggest mis understanding in mind of non IT people. They just believe that a computer programmer can repair any computer and can fix Windows. They can repair any part of computer including RAM and Hard disk and even Processor. Now this is a limit. How one programmer will know about hardwares? And hardwares like hard disk and processor is highly configured hardwares and need special environments and tools and skills to do that. It's not like open the CPU, take out hard disk, smashed hammers on it and done, it's repaired. Yes we can do small things like open CPU and adjust RAM and check for any loose connection and if that fixes the PC and then it's well and good. But beyond that we can not do anything. WE CAN NOT CREATE A COMPUTER

Same goes of operating system, if windows is corrupted or not working properly due to virus, a programmer can not fix it just like that. Operating system like windows are too much complex system and if its broken, it need to be repaired by expert who knows about it. Off course some programmers do know much about it and can fix the things but not all programmers can do it. So please spare us with this. 


Do You Develop Websites?

No all the programmers do not just make websites , there are so many fields and functions in IT industry like mobile app, desktop app, cloud development, server admin etc. And all the programmers will have their own specializations. Some of the programmers create mobile app, some are experts in creating desktop applications. And anyways, internet is not just about websites, there is much more and for each field and functions, there are programmers who are expert in it.

Type Without Looking At Keyboard and Type it Faster

Programming is not just about writing stories, where we just have to type characters and alphabets and just numbers. Every computer language has strict syntax to follow when writing code and creating programs. 

For example, there should be semi colon ( ; ) at end of each statement when you are using PHP language. When we are writing a code we uses lots of characters like

: colon
; semi colon
( ) [ ] { } all type of brackets
, comma etc.

So we have to look down and see if we are using correct character. And we can not type faster while writing a code as when we are writing a code, we also have to think if it's correct or not and make sure there is no error or syntax error. So 


Are You Writing Code All Nights?

Yes it's a fact that computer programmer works till late night or would like to work till late night but this is not usual scenario and we do not write code all nights. We are normal people and would like to rest like normal people do. We like to work till late night but not at a cost of our health and besides we are not machine that will work 24 hours a day with out any rest.

Do You Also Hack Computers?

A Big No, programmers are not hackers not even ethical hacking. Hacking needs good knowledge of computer hardwares and networks and not all programmers know about it. It needs some special skills and training to be a qualified ethical hackers. Yes some programmers do it for fun and out of curiosity but this is not something we do it regularly on day to day business. It's not our bread butter and besides hacking is illegal and none of the programmer would like to go on that way.

How To Be a Good Developer and Professional

Hello and welcome to third blog 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

This blog is about self evaluation. After reading this blog, you will realize  if you have what it takes to be a great developer and if you are have not this symptoms ,you have to find out your Knack.

You Should Have Knack Of Technology.

According to definition in dictionary meaning of Knack is.

  • A special talent or skill, especially one difficult to explain or teach
  • A skilful, ingenious, or resourceful way of doing something
  • A particular talent or aptitude, esp an intuitive one
So yes you need to have special talent and clear aptitude and particular attitude to be a good developer. In short you should have Knack of Technology like Little Dilbert

So yes you should be like Little Dilbert to be a great software engineer.  You should have Knack of technology and if you don't have it then you have to find it or develop it. Next we will see some questions that you have to ask yourself and find out if you have that knack or not. 

Do you like sitting in front of computer for long time? 

This if the first and foremost requirement to be a developer. Because as a developer you have to sit in front of computer and write code of long time. As you will be given a task and deadline to complete it and you have to meet that deadline. So you have to sit for long time and complete it. Sometime you may have to skip lunch, tea or dinner, you should be ready for it. In short it will be your "RACE AGAINST TIME" and you have to win it.

 Do you like to learn new things?

This is another most crucial requirement to be a good developer. Your learning will not stop after your college course. If you think I have studied enough and I will not invest my time to learn something new, you are at the dead end of your career. Because technologies come and go. Nothing is permanent. What is hot technology today will be out of the market tomorrow and something new will come and if you are not willing to learn new thing, you will be out of the race. Take an examples of programming languages.

There was a time where developers were using languages like C, C++
Then comes Java.
Then comes VB.NET,
Then comes PHP

Earlier there was VB script, then we have JavaScript

Earlier there was Objective C and now we have Swift

Earlier there was no cloud computing, now we have Cloud Computing

So things are constantly changing and if you are not willing to except change then you can not be good developer so you have to learn new things and adopt and survive it.

Can you keep calm in worst condition?

Coding is an art that we have to do with calm and composed mind. You should not be short tempered. Because while coding you may have to face situation where no matter what you do error is not resolved, you are trying for hours to get something working and it's not working as expected, you are not getting proper output. In this situation if you loose you calm and get angry then it will get worse and you will never be able to solve your problem. Do you know one missing semi colon in code can create nightmare for you. In this situation you should not get angry and search for error. Debugging is the process which needs lots of patience. You have to debug step by step and it is real time consuming.

Sometime you may have to face situation like your work is over written due to mistake or it's rejected by your leader or client and he asked you do do it again. In this case you should not punch into face of your leader or client but KEEP CALM AND CODE ON.

Do you think twice before start working?

Whenever some task is assigned to you, you have to think twice and look for the best possible solution to achieve it. Don't just start working on it with first thought come up in mind. It may be possible that you end up with disaster and you have to redo everything. And at start of your career, you could be fired for not performing well and this can ruin your career. So be careful about it and think twice before you start working on it.

Do you listen to others?

It's about being team player. In your career hardly it will happen that you will be the only person working on the project, there is always a team and when you are working in team, you have to listen to others because everyone like to give opinion and you have to deal with it, It may be possible that you gave solution to some task but from your team someone else come up with better solution. so you have to listen to them and understand what your team members are trying to say. So be a good listener, keep your ego aside and be a good team player.

Do you communicate with others?

Communicate with others is as important as listening to others. That is again a quality of team player. Your team members should be aware of what you are doing and what problems you are facing. It's possible that your work is affecting someone else's work. You have to communicate with them and inform about it. Same way if you are working on someone else work then you to ask them first about it understand it and then work on it. This will lead to less errors.

Do you like Algorithms and Flow Charts?

Most of the course on software development includes algorithms and flow charts. When you are studying it you may find it worthless and waste of time but it's actually not a waste of time. Algorithms and Flow charts are key elements of development. When you will be working on any task you have to break down it to smaller tasks and setup the flow as per the domain you are working. For example if you are building online selling website then to place an order there is a flow like

Customer registered
Customer add billing and shipping address
Customer makes payment
If payment is successful, place an order else show error. 

so that's the flow and for that you have to make up a flow chart in your mind and code as the flow. 

Same way for the difficult task you have algorithm, which is nothing but a plan to solve the problem and you have to create that plan. If you don't like algorithms then you will not be able to solve complex problems.

Do you know how to search on Google?

In the era of internet and Google, there lots of websites and forums and blogs where developers like you and me write about the problems we are facing and others in the communities give solution to this.

So it's possible that problem you are facing is already faced by someone else and there is solution already but you have to search it and find it. For this you should know how to search effectively on Google and find out solution and save your time.

Do you consider worst outcome while coding?

This is one common problem I have seen in all the developers. When they are working on some tasks, they just consider the best outcome and assume that all the inputs will be available. But this is not the case always, you have to make sure that you consider worst scenario as well and handle it properly. Do not assume that you will have all the possible inputs. If you don't consider worst scenario there will be lots of problems.

Do you take responsibility of your work and do not blame others?

As I mentioned, it's team play and in the team whenever something goes wrong, blame game starts. Nobody would like to receive criticism and try to blame others when project failed. But as a good ethical developer, you have to accept your mistake and take responsibility of your work and be open about it. There is no shame in accepting your mistakes. 

If your answer is Yes to above all the questions that means you are going to be a good developer. If your answer is NO for some questions that means you need to improve in that area but if your answer is NO for all the questions, I am afraid that you are not qualified to be a developer.  Go for other career option.

Tuesday, January 17, 2017

Some of the Greatest Programmers of All Time

Hello and welcome to second blog 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

This blog is again going to be a blog for motivation. A programmer is a person who writes the computer programs. There are those few who have contributed beyond what a single programmer usually does in an entire lifetime. They gave us reason to achieve something. In this blog we will take a look at some of the Greatest Programmers of All Time. Some of them are not with us right now but we can not forget them. These programmers are pioneers of the IT industry. Their contribution can never be forgotten. They are legends of IT industry and are role models of many aspiring programmers like you and me. Let's see some of the great programmers of all time.

Dennis Ritchie - Father of Digital Computing

Yes he is the one the best programmers of all time. He is the inventor of C language and Unix operating system. Today most of the programs and technologies uses C language and  Unix is the base operating  system, from which all the OS like Windows and Mac is created. We can say that without him all the companies like Apple and Microsoft would not exist today. Entire software industry owe a lot to this man. He is truly a father of digital computing. He won prestigious Turing Award for his research and development of Unix and also won National Medal of Technology. Unfortunately he is not with us right now but his legacy is still going on and he will be remembered forever for his contribution.

Ken Thompson - Co Inventor of Unix

Ken Thompson is an American pioneer of computer science. Having worked at Bell Labs for most of his career, Thompson designed and implemented the original Unix operating system. He also invented the B programming language, the direct predecessor to the C programming language, and was one of the creators and early developers of the Plan 9 operating systems. Since 2006, Thompson has worked at Google, where he co-invented the Go programming language.

Other notable contributions included his work on regular expressions and early computer text editors QED and ed, the definition of the UTF-8 encoding, his work on computer chess that included creation of endgame tablebases and the chess machine Belle.

Grace Hopper - Inventor of COBOL and the Word "BUG"

Grace Hopper was an American computer scientist and United States Navy Rear Admiral.In 1944, she was one of the first programmers of the Harvard Mark I computer and invented the first compiler for a computer programming language. She popularized the idea of machine-independent programming languages, which led to the development of COBOL, one of the first high-level programming languages. She also popularized use of the term BUG (already established in other technical contexts) which frightens all the developers. There is an interesting story about how the word BUG was invented. 

In early days when computers were so big and they were using big hardwares, US navy was using such computers and Grace Hopper was managing one such computer. One day computer was not working and she opened it to check it and found out that one bug was squeezed and dead in computer hardware and that stopped computer. While she was removing dead body of bug his superior came in and asked what's going and she replied "I am removing BUG" and since then word Bug is used for hardware and software failures.

Bjarne Stroustrup - Inventor of C++

Bjarne Stroustrup is a Danish computer scientist who is credited for the creation and the development of the widely used and highly successful C++ programming language. He not only invented it, but also evolved it, all by himself, by writing its early definitions, producing its first implementation, formulating its design criteria, designing all its major facilities, processing extension proposals for standards committee and its standard textbook.

James Gosling - Inventor of Java

James Arthur Gosling is a Canadian computer scientist and an officer of the order of Canada. He has coded quite a number of programs but is widely known for his creation of the highly successful and commonly used Java programming language in 1994 as well as its original virtual machine and compiler.

Donald Knuth - Father of the Analysis of Algorithms

Donald Ervin Knuth is an American computer scientist and mathematician as well as a Professor Emeritus (retired professor) at Stanford University. Knuth has been dubbed as the “Father of the Analysis of Algorithms” as he has contributed to the development of rigorous analysis of the computational complexity of algorithms and systematized formal mathematical techniques for it.

Knuth has also popularized the asymptotic notation and he is also the creator of the TeX computer typesetting system and the METAFONT font definition language and rendering system. He has contributed to several branches of theoretical computer science and has also created the Computer Modern family of typefaces.

Tim Berners-Lee - Father of World Wide Web (WWW)

Sir Timothy John “Tim” Berners-Lee is a British computer scientist who is renowned all across the globe because of his creation of the World Wide Web as well as the implementation of the first successful communication between a Hypertext Transfer Protocol (HTTP) client and server via the Internet in November, 1989.

Tim has won multiple awards for his pioneering ingeniousness such as becoming one of only six members of the World Wide Web Hall of Fame and one of five Internet and Web pioneers who have been awarded the inaugural Queen Elizabeth Prize for Engineering. He is also the holder of the Founders Chair at the MIT Computer Science and Artificial Intelligence Laboratory.

Margaret Hamilton - Lady who helped Mankind to Reach To Moon

Margaret Heafield Hamilton is an American computer scientist, systems engineer, and business owner. She was Director of the Software Engineering Division of the MIT Instrumentation Laboratory, which developed on-board flight software for the Apollo space program. In 1986, she became the founder and CEO of Hamilton Technologies, Inc., in Cambridge, Massachusetts. The company was developed around the Universal Systems Language based on her paradigm of Development Before the Fact (DBTF) for systems and software design.

Linus Torvald  - Inventor of Linux

Created the Linux kernel and Git, an open source version control system. Winner of numerous awards and honors, including the EFF Pioneer Award in 1998, the British Computer Society’s Lovelace Medal in 2000, the Millenium Technology Prize in 2012 and the IEEE Computer Society’s Computer Pioneer Award in 2014. Also inducted into the Computer History Museum’s Hall of Fellows in 2008 and the Internet Hall of Fame in 2012.

Jeff Dean - Compilers don't warn Jeff Dean. Jeff Dean warns compilers

Helped to design and implement many of Google’s large-scale distributed systems, including website crawling, indexing and searching, AdSense, MapReduce, BigTable  and Spanner. Elected to the National Academy of Engineering in 2009. 2012 winner of the ACM’s SIGOPS Mark Weiser Award and the ACM-Infosys Foundation Award in the Computing Sciences.

Well this list is end less. But who can be the next in this list? 

It's YOU and Only You.

Yes now it's your time, to register your name in this glorious list. Have a clear vision, work hard, achieve your dreams and register yourself in the list of Great Programmers of All Time.

Monday, January 16, 2017

Because All The Leaders Were Developers Once

Hello and welcome to my new blog series "Fresher to Professional".  

This blog is for the beginners who are looking forward to start Career as software engineer, programmers, developers, designers. This blog will teach you real skills and attitude you need to be a successful IT professional. During my 10 years of Career I have realized that real trainings are missing when you start and that is affecting your Career in long run. I will share knowledge gained through out my Career that will help  you build your Career to top notch professional level. 

This is the first blog of this series and it's all about motivation. Yes motivation is the kay factor when you are starting your Career because you don't know about future and you must  have heard good and bad things about the Career you are about to start. So at this point either you are excited or you are little bit suspicious about your choice or you are totally frustrated about it. Every computer graduate who is starting a Career in IT must have heard some things which are enough to discourage you. Among it the worst thing an aspiring software engineer has to listen is..

Ahh Just Another ONE

Yes this is one thing which each IT professional has to face at a start of the Career. Whenever you tell someone that I am a computer engineer they will consider you JUST ANOTHER ONE of the heard. Unfortunately it's true. With the booming IT industry lots of people choose this as Career option and lots of computer and IT engineers are  graduating each year. There are lots of colleges, private institutes which offers various courses in IT and there are lots of students who choose it and come out as IT professional and it's increasing each year. So the society think that a COMPUTER ENGINEER is just another one who will start working as developer and will work for long hours with very less pay and lots of stress.  And this is right at certain point of time when you are starting as a fresher you have to work hard, you have to show your dedications, you have to learn new things and most important is you have to make sure that you don't become "JUST ANOTHER ONE".

Well no this is not true, 

We are not JUST ANOTHER ONE, We have potential to make a difference and be THE ONE

Do you know what's your value in IT Industry. Checkout this video.

Well, that's the Steve Balmer, former CEO of Microsoft, and he is praising you by this song, so you can understand how valuable you are.

Yes IT industry is all about developers.

Each IT professional, if trained and guided properly at start of the Career, they can be THE ONE. If you have that killer's instinct to do something different and have will power, dedications and you are willing to work hard, you can be THE ONE and make a difference. Every beginning is the small one and but the end depends on you. You can make it bigger or you can be just another one and finish it like everyone else. Do you know that the current leaders, the technology icons were once a developers or programmers just like you and me but they did something different and today they become the leaders. They started with small things but today they become giant and no one can beat them. Here are few examples. 

The Infosys Team

N. R. Narayana Murthy, Nandan Nilekani, N. S. Raghavan, S. Gopalakrishnan, S. D. Shibulal, K. Dinesh and Ashok Arora

Co-founded in 1981 by 7 Engineers,  after they resigned from Patni Computer Systems.The company was incorporated as "Infosys Consultants Pvt Ltd." with a capital of ₹10,000 or US$250 in Model Colony, Pune as the registered office. It signed its first client, Data Basics Corporation, in New York City.In 1983. Today Infosys is the giant of Indian IT Industry. It's one of the biggest company of India with development center across the India and abroad. Today Mr. N. R. Narayana Murthy is considered as a visionary and an icon of IT industry. Mr. Nandan Nilekani worked with Government of India for many IT projects including Aadhar - UIDAI. 

The Apple Team 

Steve Jobs, Steve Wozniak and Ronald Wayne

Apple was established on April 1, 1976, by Steve Jobs, Steve Wozniak and Ronald Wayne to sell the Apple I personal computer kit. Later they have introduced series of personal computers like Apple 2, Lisa and most successful one Macintosh. In early days of apple,  Steve Jobs and Steve Wozniak used work in Steve's Garage with a small team. They really struggled to sell their products and raise money for the new products. Today Apple is the most valuable technology company with products like iPhone, iPad, iPod, Macbook, iMac and one of the successful series of OSX operating system. They created all new market for mobile application developers. 

The Google Team 

Sergey Brin and Larry Page

Just like Apple Google was also started in garage. Larry Page and Sergey Brin dropped out of the college to start internet search website. They worked hard to come up with unique and robust search algorithm. Once Google was founded, there was no looking back for this duo. Today Google is considered as most robust search engine and most valuable technology company. Today they have introduced many products like Gmail, Google Glass, Youtube, Self Driving Car, Google Fibre, Android and they keeps on inventing new things everyday.

The MicroSoft Team 

Paul Allen and Bill Gates

Paul Allen and Bill Gates, childhood friends with a passion for computer programming, sought to make a successful business utilizing their shared skills. They co founded Microsoft as Software Development firm and worked with IBM on creating MS DOS. Later they have introduced their own operating system Microsoft Windows. Which can be considered as most successful operating system in the history. Today Microsoft is one the most valuable technology company. Like all of us Bill Gates and Paul Allen worked really hard in initially days. Bill Gates used to write codes for hours while they were working on MS DOS. Today lots of programmers writes code for him.

The Facebook  Team 

Mark Zuckerberg, Dustin Moskovitz, Eduardo Saverin, Andrew McCollum, Chris Hughes

Facebook was founded by Mark Zuckerberg in Stanford University Room along with his few class mates. He started it as social networking site for Stanford and today it's worldwide social networking site. He with class mates wrote millions of lines of code for Facebook website and today he is in the list of billionaires. He employs people older than him to work for him. 

So the moral of the story is if you are starting your Career as a developer or programmer, you have a chance to make it big if you work really hard and if you have clear vision. You can also be like these leaders in future. Each start is small one but the end can be giant.  So do not feel that you are less than doctors and managers. You are unique as a computer engineer and you have a potential to make it different and stand out from the crowd and be the ONE. So do not listen to any criticism about yourself, do not believe in all that rubbish stuff, focus on your goal and work hard, you will be successful in your IT Career.  Your start is not small because

Because All The Leaders Were Developers Once

Saturday, January 14, 2017

AVCaptureVideoPreviewLayer Black Screen. AVfoundation Black Screen on Record

Recently in one of my project we used AVFoundation to record video. In some of the iOS devices, we were getting issue that on start recording, it shows black screen and video is not recorded. After some investigation I found out that it's because user has manually revoked camera access from settings so it was not woking. So to solve this issue, you must check if the permission is there or not. If not first request permission and if it's denied, so message to user.

So here is the function you should use. You should call this function, before you start recording and check if there is necessary permission.

- (void)requestCameraPermissionsIfNeeded {
    // check camera authorization status
    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    switch (authStatus) {
        case AVAuthorizationStatusAuthorized: { // camera authorized
            NSLog(@"requestCameraPermissionsIfNeeded camera authorized");
            // do camera intensive stuff
        case AVAuthorizationStatusNotDetermined: { // request authorization
            NSLog(@"requestCameraPermissionsIfNeeded have to ask user again");
            [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    if(granted) {
                        // do camera intensive stuff
                    } else {
                        NSLog(@"STOP RECORDING");
                        WeAreRecording = NO;
                        ShareVideo = YES;
                        [MovieFileOutput stopRecording];
                        //Prompt message to user.
        case AVAuthorizationStatusRestricted:{
            NSLog(@"STOP RECORDING");
            WeAreRecording = NO;
            ShareVideo = YES;
            [MovieFileOutput stopRecording];
            //Prompt message to user.
        case AVAuthorizationStatusDenied: {
            NSLog(@"STOP RECORDING");
            WeAreRecording = NO;
            ShareVideo = YES;
            [MovieFileOutput stopRecording];
            //Prompt message to user.
            dispatch_async(dispatch_get_main_queue(), ^{

This will help you in identifying issue and display proper message to user.

Thursday, January 12, 2017

Don't get Trapped In Code Refactoring

This blog is coming out of discussion with one of my old client. I worked with him for almost 5 months in year 2010, that is 6 years ago. We build a nice hybrid mobile app. Recently we had a talk about a new product. During our conversation I came to know that for one of his other product he hired a developer and it took almost year to build a product which was originally estimated for 3 months.  That was bit surprising for me so we discussed more about it. Client said, the developer took most of the time in changing the code so many times, however output was the same and there was no functionalities changes . So immediately I understand, developer refactored code so many times Client asked me is it necessary to change the for the things so many times which are already working?  Well yes that's the important question, at what level refactoring is good?

For the readers who are not aware of refactoring, here is some information about code refactoring. 

"Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behaviour. Refactoring improves nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity; these can improve source-code maintainability and create a more expressive internal architecture or object model to improve extensibility. Typically, refactoring applies a series of standardised basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that either preserves the behaviour of the software, or at least does not modify its conformance to functional requirements. Many development environments provide automated support for performing the mechanical aspects of these basic refactorings. If done extremely well, code refactoring may also resolve hidden, dormant, or undiscovered computer bugs or vulnerabilities in the system by simplifying the underlying logic and eliminating unnecessary levels of complexity. If done poorly it may fail the requirement that external functionality not be changed, introduce new bugs, or both."

Since I started working as a software developer, code refactoring always confuses me. Every time I refactor a code, I am not sure if I am doing it right or wrong. 

In my frank opinion I also believe in refactoring in code and make it more simpler to amend future changes easily and to make it more understandable by others. Code refactoring is good, but my confusion is at what level and how many times? 

I still remember my team lead when I was working as a software engineer, My team lead always come to me and there is always one instruction, "Hiren, reactor your code" and I do reactor code by all means and make it more reusable.  But at certain point I think it's useless, the code is already in good condition, why should I make it more complicated? Is it really necessary? 

There are two output of code refactoring, either it will make code better or it will make it worse. Worse to the level that it will introduce many bugs and only option then you will have is to rewrite code. And why shall we make such complex code that nobody can understand and it's not necessary when things are working fine. Code refactoring is not going to change output, yes it may improve performance, but it will be at some level, beyond that no matter what you do, performance will remain same. So it does not make any sense to refactor the code. Its waste of time and money. Yes unless you want no one to understand your code, you can make it complex by refactoring it many times. This way you will have patent of your code and nobody will be able to change it. But this does not make any sense when you are working in team. Code refactoring is sometime end less, you just keep on refactoring the code and you will never finish the project.

So in my opinion, code refactoring is good at certain level, not beyond that. Don't get trapped in refactoring. 

Monday, January 9, 2017

10 Years of iPhone

Today is the one of the historical day for IT industry. Ten years ago today, on Jan. 9, 2007, Apple co-founder Steve Jobs, unveiled the product that would drive Apple to become the most valuable company in the world and cement Apple’s comeback as the greatest in business history. At the Macworld conference in San Francisco, he unveiled the iPhone.

Here is his Key note speech, in which he introduced iPhone.

Off course there was something crazy about iPhone. It changed mobile industry entirely and introduced Mobile Application economy with introduction of App Store, where developers can upload their apps and can make money. That created entire new opportunities for mobile application developers. Since it's introduction there are number of versions of iPhone are introduced with exciting features and cool UI display.

Being a mobile application developer I daily work with iOS devices and also other mobile devices here are some points which I feel are very spacial in iPhone.

Very Stable OS and Hardware support

Being a mobile application developer I work with both android and iOS devices but at one point every developer has to struggle with android while dealing with hardwares such as camera or SD card or any other native features. While in iPhone this is usually not the case because it has stable SDK and hardware which are manufactured by only Apple so we don't see much changes and customizations. While in case of android, since it's an open source operating system all the phone manufactures have changed it and customized it as per their platform. So face bit of problems while working with hardware. One app working without any issue in one phone may not work in other phone. While in case of iPhone, app will work all the devices and all the iOS versions.

Nice Development tools like Xcode IDE and Simulators

This is another advantage iOS development we have very stable Xcode IDE and iOS simulators using which we can develop applications very easily. In most of the cases you don't need real devices. Using simulators you can easily develop and test apps and launch in apple store. Xcode is not changed much since it's introduction and it's very easy to use, yes with the introduction of Swift, we have to learn new languages not but that's ok, that change is good.

It's not like iPhone is good in all the cases, there are some drawbacks.

Tooooo Expensive

This is first and foremost drawback for mobile application developer. Some features if you want to test like push notifications or cameras, that will work only in real devices and you have to buy it and it's too expensive for the developers. Developers can hardly afford one or two devices not more than that. Due to which sometime it gets hard to test some apps. As a mobile app developer I am still dreaming of having my own iPhone since years but I didn't manage to get it yet.

Bit Complex Testing Process and Publication Process

Compare to android, testing and publication process is bit complex in case of iOS. For Android you can share APK with any android devices and it can be installed and tested easily. While in case of iPhone, you need  apple developer account and create developer certificate and provisioning profile and register device Ids and upload app for testing and get it approved before you can send it to someone for testing using TestFight. Also to publish the app in market, you have to maintain some standards in case of UI and features, otherwise it's possible that your app may be rejected by app store and you have to redo again and make changes and republish app.

In short being a developer sometimes iPhone looks like blessing and sometime we feel that

Life Was Much Easier When Apple And Blackberry Were Just Fruits

Here is one funny video about it, Have fun and happy coding.

Sunday, January 8, 2017

Advantage of Research and Development

This blog is coming out of the recent conversation with my brother. He is a research scholar and holds Ph. D. in Environment Science. He usually write Research Papers which are published in renowned Environment Science Journals worldwide. He came up to me and said.

Brother : Hey, today my 10th research paper published in Environment Science Journal

Me : Oh good, I am also an author of technical book. (I authored a book for Packt Publishing) (You know, the jealous factor is very common between siblings)

Me: How many pages in research paper?

Brother: It's of two pages.

Me: Is that it? My book is of 70 pages and it's sold at $10 USD per copy.

Brother: My research paper is published in a Journal which is sold at $2000 USD per copy and it's subscribed by global universities and organizations. 

Me: Ohh Pooh... (Speechless)

Well yes it was a money factor which I was considering but later on I realized that yes my small book is nothing compared with two pages of research paper. It's all about content that matters. A content of two pages of research paper is far more valuable than content of 70 pages of a technical book. Because that content is coming out of hard work, that includes months of research and experiments and lots of other things.

R&D is key factor of innovation in all fields. Without R&D we would not have great things which we are using right now in all the fields. Research and Development plays a critical role in the innovation process. It’s essentially an investment in technology and future capabilities which is transformed into new products, processes, and services.

Research and Development departments are common in many larger companies, especially those working with newer products or technologies. While research and development work can be instrumental in creating new products or adding features to old products, the work that the department does is more complex than simple innovation.

Moral of the story is : Do not under estimate Research and Development and do not show off your work to Research Scholar.

.htaccess Doesn't Work in Amazon AWS EC2 Instance with Ubuntu

Recently I was configuring Laravel application in Amazon AWS EC2 instance which was having Ubuntu and Apache installed. The problem was htacess file was not working so Laravel routes were not working. Instead of parsing laravel routes it always shows error URL not found.

The problem is by default in apache installed on ubuntu doesn't have .htaccess enabled so first you have to manually enable it in config file and restart apache.

Here are the steps.

1) Login to your EC2 instance with SSH.

ssh -i "Yourkey.pem" ubuntu@yourpublicip

2) Enable Mode Rewrite, this is just incase if it's not enabled.

sudo a2enmod rewrite

3) Go to following directory.

cd /etc/apache2/sites-available

If you use LS command here you will see following file.


That's the file with default apache configuration which are applied to your sites in /var/www/html folder.

4) Open this file for editing.

sudo nano 000-default.conf

5) Add following lines after DocumentRoot /var/www/html line.

<Directory />
     Options FollowSymLinks
     AllowOverride All
<Directory /var/www/html>
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     allow from all

6) Save the file and restart the apache.

sudo service apache2 restart

that's it and now your .htaccess file will work and your laravel application will start working.

Cordova FacebookConnect Plugin Not Working in iOS 9 and iOS 10

Recently in one of my Cordova project we have Connect with Facebook functionality where I have faced certain issues to make it working in iOS 9 and iOS 10 so in this blog I am going to explain those issues and how to resolve it.

1) Which Plugin to Use

There are two plugins if you search for Cordova Facebook Plugin. Following are two links.

GitHub - Wizcorp/phonegap-facebook-plugin

GitHub - jeduan/cordova-plugin-facebook4

The first plugin is older one and it works good till iOS 7 and iOS 8 and cordova 4.0 iOS but it does not work for iOS 10 and Cordova 6.0. If you use that plugin you will usually get issues like you will not be redirected to Facebook in mobile safari or after authentication, it come back to your app and nothing happen.

So my recommendation is to go for second Plugin, which works fine with latest cordova and iOS 9 and iOS 10.

2) After authentication, it come back to your app and nothing happen.

This issue is observed in iOS 9 and iOS 10 for both the plugins. That's because of LSApplicationQueriesSchemes introduced in iOS 9 on words.

There are two URL-related methods available to apps on iOS that are effected: canOpenURL and openURL. These are not new methods and the methods themselves are not changing. As you might expect from the names, “canOpenURL” returns a yes or no answer after checking if there is any apps installed on the device that know how to handle a given URL. “openURL” is used to actually launch the URL, which will typically leave the app and open the URL in another app.

Up until iOS 9, apps have been able to call these methods on any arbitrary URLs. Starting on iOS 9, apps will have to declare what URL schemes they would like to be able to check for and open in the configuration files of the app as it is submitted to Apple. This is essentially a whitelist that can only be changed or added to by submitting an update to Apple.

So you have to WhiteList all the Facebook App Schemes in your info.plist file. Following are schemes you have to add.


3) There was an error making the graph call

I spent almost an hour to solve this issue. Everything was configured but when I try to make graph API call to get basic profile, it fails every time and the reason behind this was in graph api call IO have space after each field.

facebookConnectPlugin.api("me/?fields=id, first_name, last_name, email",["public_profile"],
function (result) {
function (error) {

As you can see above there was a space after each field. So to make it working. Remove that space. It does not affect in Android but it does not work in iOS.

function (result) {
function (error) {

Wednesday, January 4, 2017

FMCG Suppliers - Improve Order and Inventory Management With Mobile Application

In this blog I am going to explain how FMCG suppliers can improve their order and inventory Management with Mobile Applications.

In the past we have built eCommerce solutions for FMCG suppliers and from our experience and research we found some issues faced by FMCG suppliers in their order and inventory management.

No Brand Awareness Among Customers

Most of the FMCG suppliers either supply their own brand or promote some other brands but their customers are not aware of those brands as there is no information available of that brand to customers. Customers do not place order for that brand and eventually brand does not work.

No Product Availability

Customer places an order with certain products but those products are not available in market hence either order is canceled or delayed and customers are not happy. Main problem here is order management is not connected with inventory management. There is no information in low stocks hence orders are placed but there is no stock. Even customers are not ware about delays hence they get frustrated and eventually cancels orders.

Inefficient Distribution of Orders

There is no proper information of stocks in inventory hence orders can not be fulfilled, specifically in case of multiple warehouses. Sometime orders goes to warehouses where items are not available. So order can not be fulfilled or gets delayed as it goes from one to other warehouse. Even customers are not ware about delays hence they get frustrated and eventually cancels orders.

Inefficient Schedule of Deliveries

Customers are spread across various locations but they don't have proper location information hence order delivery is not planned properly and there are no proper distribution routes. Hence cost and time of deliveries in increased which leads to lesser profit and chaos in supply management. 

No Data and Analytics of Past Orders of Customers

They don't have proper data of past orders of customers and there is no analytics so they can not identify target customers for specific goods and items and they can not offer better rates and offers to them on specific customers. 

To over come this issues FMCG supplier can go for solutions with mobile application for their supply chain management and orders and inventory management. With mobile applications orders, dispatch , shipping and salesman there will be significant improvement in their sales and orders management.

Benefits of Mobile Application for Orders

Your customer will use this application for placing orders. Here are some benefits of it.

  • Brand awareness
  • No delay any placing orders
  • Feedback on orders
  • Instant notifications of order status
  • Instant notifications on order cancelation
  • Real time tracking of orders and movement
  • Promotional schemes
  • Orders and items analytics
  • Surveys and polls

Benefits of Mobile Application for Salesman

Your salesmen will use this application to place orders and see analytics. It enables the field guys to effortlessly conduct processes like order booking, payment collections, filing daily sales reports, merchandising operations etc in real time. 

  • Route planning
  • Activity planning
  • Visit reporting
  • Complain reporting
  • Competition tracking

With our solution for FMCG suppliers, you will get following benefits.

  • Seamless visibility on daily product movement including stock transfers
  • Accurate information on sales, collections, sales returns across the distribution channel in real time
  • Shorter order to cash cycle
  • Improved market coverage
  • Analytics like monthly sales, per area, per customers
  • Improved logistics and cost cutting because of route planning
  • Better inventory management with low stocks notifications
  • Better dispatch management

If you are looking for such solution for your FMCG business, contact us now.

Monday, January 2, 2017

Android MediaRecorder Stop Failed - 1007

If you have ever used Android MediaRecorder to record video or audio in your android application, you must have faced this error. Recently I had nightmare in using MediaRecorder in my android application. I think it's most unstable class in Android SDK and there is a different behavior in each device. In this blog I am going to explain more about this and possible resolution of this.

First lets see wha's the meaning of this error : Android MediaRecorder Stop Failed - 1007

There is no documentation on Android developer site about this error code but from my experience I found out that there are three reasons behind this error

1) You called stop method too early.

According to documentation on class it says

Stops recording. Call this after start(). Once recording is stopped, you will have to configure it again as if it has just been constructed. Note that a RuntimeException is intentionally thrown to the application, if no valid audio/video data has been received when stop() is called. This happens if stop() is called immediately after start(). The failure lets the application take action accordingly to clean up the output file (delete the output file, for instance), since the output file is not properly constructed when this happens.

That means if you start recording and in couple of seconds you call stop recording there is no significant data of recording hence stop method throws an exception. So you must wait for sometime. From my testing I found out that you should at least for minimum 10 seconds. So the solution is to have stop method called inside try catch block and handle the exception properly or do not allow user to stop recording till 10 seconds of start of recording. You can either disable stop button and make it enable after sometime. Once the exception is thrown, you should clean the the resources, release media recorder and camera and all other objects.

2) Error in Writing to Output file

We have to set output file to MediaRecorder when we start recording. When you stop all the recorded data will be appended in output file specified by you on start. This could failed due to reasons like insufficient space to write file or you don't have permissions to write to external and internal storage due in Android 6.0 on words.

3) MisMatch in preview size and video size set in MediaRecorder

I have mentioned about this in my previous blog. You can read it here.

Android MediaRecorder Start Failed - 19

Hope this helps you and save you time.

Improve Your Marketing with Big Data Analytics of Locations Visited by Your Sales Persons

Many people believe that great marketing is an art form, but lately big data has added a serious dose of science into the mix. Smart marketers are now relying on data more than ever before to inform, test, and iterate their strategies. Organizations can make use big data analysis and can improve their marketing strategy. By using big data analysis organizations will have clear insight of their sales and its outcome and using which they plan strategy accordingly. They can also predict the future growth using current data and can have plan on that. They will know about clear ROI (Return On Investment). I will explain it by some practical investments.

We have mobile app for tracking sales persons. You can get more information from here.

Employee Tracking Application for On Field Employees - Adsum Mobile GPS APP

With this we get locations visited by sales persons everyday. These locations data could be in millions for each month and years and with our Big Data Analytics and using our Mobile Application you will get following informations.

Most Frequently Visited Areas for Sales

This will give you clear demographic information about your customers, where they are, in how many numbers are they and amount of sales generated from each area. This will give you clear insight about your demographic reach. You can implement future marketing strategies and deploy heavy sales sales force in area from where you get maximum leads. These location based information will be useful for you to target sales in particular area at particular time.

Optimize Customer Engagement

With location analytics you will now that where they are, what they want, how often they make a purchase, when and how they prefer to be contacted, and many other important factors. This way you can have better customer engagement.

Most Effective Sales Persons

With the location data analytics, you will know that who can be your salesman of the year as you know that how many areas a sales person have covered, how many KMs he has travelled on an average and how much sales he has generated from each area. This way you will know the strength of your sales person in particular area and you can define your sales strategies according to that and send your nest sales persons to the area from where you get maximum business.

Manage Your Traveling Expenses

As you reimburse traveling expense of your sales person each day, with this data you will have clear information on your ROI of Traveling Expense. As you will have report of traveling expense vs sales vs areas so you know that from which area you get maximum returns.

If you want this solution, contact us and know more about it.