The Great Indian eCommerce Sites

Standard

Yesterday I was browsing for Mac Mini as that seemed like a good value for money option compared to iMac. Since I am an Amazon loyalist so I first went to Amazon where it was listed at Rs. 36,391/- with a MRP of Rs. 36.990/- as shown in the pic below.

Mac Mini Price in Amazon

Price on Amazon was very much what I anticipated but still I thought I’ll take a look at what others are quoting for this item so I opened Flipkart. On Flipkart, the same product was listed at Rs. 41,500/-. There was no MRP specified so it’s safe to assume that the MRP of the product, as per Flipkart, was at least the price at which it was being offered, i.e. Rs. 41,500/-.

Mac Mini Price in Flipkart

But wait, wasn’t the MRP on Amazon for the same product was less? Yes, it was. Rs. 36.990/- to be exact. Confused? This is nothing. Read on.

Next, I went to Snapdeal and searched for the same product and here is what I saw.

Mac Mini Price in Snapdeal

So Snapdeal was offering the product at Rs. 37,997/- (better than Flipkart) but hey, what’s that MRP? On Snapdeal, MRP was mentioned as Rs. 40,900/-.

Now this means that the MRP listed on both Amazon and Snapdeal for the product was less than the price at which Flipkart was offering the product. How’s the possible? It essentially means that Flipkart is selling the product at higher than MRP. Remember there was no MRP specified on Flipkart.

Another question is how come the MRP itself is different on different sites? There is a possibility that even though the model is same, some sites have older or newer stock resulting in the difference in MRP but I didn’t find any such difference from the product description and specifications though it may not have been specified anywhere.

Anyhow I didn’t stop there and searched for the product on Google and came across this listing on Vijay Sales which is a large (primarily offline) retailer of electronics and appliances. And guess what? The MRP specified, as shown below, was again different though it was very close to the MRP on Snapdeal. On Vijay Sales, the MRP was Rs. 40,990/- (Rs. 90/- more than Snapdeal).

Mac Mini Price in Vijay Sales

Now how it is possible that the MRP of same product is different on 4 different sites? It makes me think that there is something fundamentally wrong the way these sites are displaying the MRP, discounts and price. One primary reason is clearly to show higher (than actual) MRP and low offer price to come up with a higher percentage of discount. After all, a 20% discount looks better than 5% discount if you’re not comparing the final offer price on multiple sites.

For a moment, I wanted to keep going and checking out the price and MRP of the product on some other (smaller) sites but then I remembered I had better things to do 🙂

So here are my takeaways from this.

  • Amazon seems to be the best option as I have generally found. It was offering the product at lowest price and least MRP. (Yay! My trust in Amazon isn’t broken with this discovery)
  • Flipkart comes across as shady as the price is highest among all 4 sites and there is no MRP shown. If you compare, the price of Flipkart is higher than the MRP mentioned on all other sites. You don’t have to be Einstein to understand what that means. My advice – stay away!!
  • I have generally found that the price difference between Amazon and Snapdeal is the least and a few times, I have found products on Snapdeal cheaper compared to Amazon so I usually check the price on both Amazon and Snapdeal before I buy something. Probably you should too if you’re not doing it already.
  • Finally, there is something fundamentally wrong with the way Indian ecommerce sites are manipulating the prices, discounts and even MRPs to increase their sales though I am not sure if they’re succeeding. An average Indian online buyer is intelligent enough to see through such manipulations.

NOTE: The screenshots were taken on 27th June (2016) evening so the prices may have changed now.

[How to] Global progress indicator for ajax requests in jQuery

Standard

Showing a loading icon (like the one below) when an ajax request is running is a common practise to ensure end-user is aware that page/information is being updated in background.

ajax loader icon

While developing large scale web applications where one might have numerous ajax requests in the code, it might result in duplication of code to show and hide the loader for each and every ajax request individually.

Instead of writing the code to display and hide the loader for every ajax request, you can add the code below to your layout (common file included in all pages, e.g. footer). But if you do not have a common layout then the code above won’t help you since you’ll end up copy pasting the same code in all files individually which would result in same issue (code duplication) that we are trying to overcome here 🙂

Assuming “loader” is the ID of icon/image (or parent element), you can use the code below.

This would not only save some amount of time which could be utilised for other productive things, it would also help in avoiding unnecessary code duplication. You can use these handlers for anything other than showing/hiding loader as well.

Note that if you are making the ajax request with global option set to false then ajaxStart and ajaxStop events wouldn’t fire. By default global is set to true so you can actually use the global option to control for which requests you would like to show the loader icon. If you do not want to show the loader for a specific ajax request then set global to false. For example,

There are some other global ajax event handlers in jQuery you can refer to see if they suit your use case(s) better.

Happy coding!!!

How to automate Social Media Marketing

Standard

If you’re a startup or a small business, it’s likely that you are not able to spend as much time and efforts as you want on social media marketing for your business despite knowing it well that social media can be an incredibly effective way to gain more traffic and generate new leads. Reasons are manifold – lack of time, lack of clarity on where to start, unavailability of affordable tools to manage and automate social media activities, not knowing how to do things the right way and so on.

Wouldn’t it be better if there was a tool which would not only help automating your social media marketing activities but also provides you an effective way to research targeted content to share on social media as per your requirements. Well, you’re in luck because now there is a tool available which does it all, and more.

Let me introduce you to Social Media Marketing Dashboard. It helps reaching your social media goals in the most easy yet in a very efficient way without taking up lot of your time and money. Did I mention it doesn’t cost you a dime? Yes, that’s right. The tool is FREE of cost and there are no limitations on how long you can use it for. All you have to do it create an account and start using it. There is a pro version which comes with more powerful features however you will find even the basic version fully functional and extremely useful.

You must be wondering though this tool sounds great but how does it actually work?

How Social Media Marketing Dashboard works?

  • It finds relevant content including videos, news, trending content all of which can be posted on your social media accounts with the click of a button.
  • It creates incredible image posts without any photo editing experience.
  • It saves time by having all social media in one place with the ability to schedule posts across multiple platforms.
  • It measures all campaign performance to help you get more traffic and generate new leads.

Here is how the social media marketing dashboard would look like once you have setup your account.

Get your free social media marketing dashboard

Get your FREE Social Media Marketing Dashboard

Moving MySQL InnoDB data files

Standard

If you ever need to move around MySQL data files for InnoDB tables or getting the error mentioned below then follow the instructions in this post.

Note that this post might be helpful only if you have a backup of complete data files directory from your source MySQL installation. Otherwise please refer to the links at the bottom of this post.

Take backup of your data files (source)

Copy your data files from /usr/local/mysql/data/ on Mac or /var/lib/mysql/ on Ubuntu/Linux to a safe location, e.g. inside your home directory. Location of data files can be different so refer to your MySQL configuration file (my.cnf) for correct path.

mkdir ~/db-files/

On Mac

On Ubuntu/Linux

Do not forget to copy the period (.) at the end of commands above.

Restore files (destination)

Stop the MySQL server on target system, if running.

On the new/target installation, replacing the target data directory contents with source data directory may not work, specifically if you have InnoDB tables.

Take a backup of data files on the destination and keep them safe somewhere in case anything goes wrong. Assuming that target data directory location is /usr/local/newmysql/data/

Extract the compressed archive of source data files.

From the extracted contents, manually copy the database folders under destination data files directory. Do not copy/overwrite any files or folders inside destination data directory, for example sys and mysql folders. For example, if one of the database name is mydb and destination data directory path is /usr/local/newmysql/data/ then execute the following command.

cp -R mydb /usr/local/newmysql/data/

This needs to be done for all your databases one by one. Any files or folders which pre-exist in the target data directory must not be overwritten. If you do then there is a fair probability that you are doomed.

Once you have copied all your databases manually (without overwriting any existing folder or file) to the target data directory, copy/replace ibdata1 file from your source directory to target data directory

Finally, ensure that ownership and permissions of folders and files inside destination data directory are correct. Data directory itself and it’s content must be owned by mysql user, _mysql  in Mac and mysql in Ubuntu/Linux.

On Mac

On Ubuntu/Linux

I am not 100% sure but permissions should be as mentioned below. These permissions work on my Mac correctly.

755 (rwxr-xr-x) for mysql top data directory

700 (rwx——) for each database directory

660 (rw-rw—-) for database files inside database directory

Lastly, restart the MySQL server and verify if everything is as expected.

Summary

The most important part is the one related to ibdata1 file. This file stores lot of information and data about your InnoDB tables along with an internal index to all the InnoDB tables. If you don’t replace the ibdata1 file related to your original/source data files then that index would be lost and MySQL would fail to understand the schema and data too would be lost despite having ibd and frm files in place.

Here are links to some useful discussions/posts related to the topic for reference.

What is the ibdata1 file in my /var/lib/mysql directory?

How to restore table stored in a .frm and a .ibd file?

Recovering an InnoDB table from only an .ibd file.

InnoDB Corruption Repair Guide

Hard work Vs Smart work

Standard

I was screening resumes for a job opening when I came across a resume where the applicant mentioned “Not hard but smart work” as one of his strengths. This got me thinking whether smartness can really be a substitute for hard work … or vice-versa?

Some people believe that smartness is god-gifted hence either you are smart (read born smart) or you are not. Others believe that smartness is a skill which can be developed like any other skill. And finally, there are some who believe smartness is a combination of both (trait and skill) and governed by factors such as one’s surroundings, environment, life experiences and so on.

Similarly, hard work can also be attributed to both trait and skill along with various factors affecting it. But there is a difference – some people work really hard while doing certain tasks but are quite lazy otherwise. I have been accused of being both, lazy and hard working, but for different type of tasks.

In my perception this is something which differentiates hard work from smartness. If one is smart, it would generally reflect in whatever that person does but the same can’t be said for hard work. If a person enjoys doing something, (s)he would naturally work hard doing it without even realizing it. You can find many examples of this in your day to day life.

Image Courtesy - innov8tiv.com

Image Courtesy – innov8tiv.com

Quote above provides another interesting insight on the topic. It basically means that lazy people are smart but by no means, it implies hard working folks are not smart. One might discard the quote as an individual perception but I have personally known a few people for quite some time who can be as lazy as a sloth yet fit the definition of “smart” quite convincingly.

Coming back to the topic whether smartness is a substitute for hard work or vice versa, let’s consider the matrix below.

hard work vs smartness

Based on assumption that the task at hand is not physical but require mental abilities

It’s safe to assume that both hard working and lazy people can be smart. Someone who is both hard working and smart (2nd quadrant) is clearly the best option. Someone who is smart but is lazy (1st quadrant), should not be a very bad choice after all. Come on, even Bill Gates approves it 🙂

Let’s look at the bottom part of the matrix now. If someone is hard working but isn’t smart (3rd quadrant) then it presents a dilemma. Though it’s likely that the person would be able to complete the task satisfactorily, in general a smarter person would complete it in either shorter period of time or in a more efficient way, or possibly both. This creates a may be, may not be situation for someone belonging to this quadrant.

Someone who is neither hard working nor smart (4th quadrant) is clearly not an option.

So where does this leaves us? Well, it seems that smartness may cover up for hard work to a good extent but the opposite doesn’t seem as promising. But the question here is – why get stuck in bottom part of the matrix at all when we all have a choice? I believe that smartness may be a trait but it is also a skill. Even when one is not “born smart”, (s)he can develop the skills needed to qualify as “smart”.

When we come across someone “smart”, it generally means that the person has the knowledge and the ability to analyze the given situation to come up with an appropriate response, action or solution, depending on the context. If one is determined and works hard, there is no reason (s)he can’t acquire the knowledge and necessary skills to fit in the second quadrant. The matrix above holds true only if one isn’t willing to work hard to reach the top from bottom.

Hard work is a choice anyone can make and if you make that choice, there is nothing which can stop you from achieving your goals even if your goal is to become the smartest person on the planet. On the contrary, doesn’t matter how smart you are, you can’t succeed always without working hard. And those who think smartness is all they need, they are in for a rude shock.

As for the resume which started this train of thought, I hope you can make a good guess about what I did with it. 

How to Use Third Party Autoloaders in Yii

Standard

Using third party libraries in Yii is super easy. Just put the library, e.g. Google, under vendors directory and add the following lines at the beginning in your controller where you wish to use it.

Alternatively, you can include the first line mentioned above in your Yii application’s main.php imports section as shown below (line 4).

And then include the desired file in your controller (2nd line) before using it. That’s all.

However, you might run into issues if you are integrating a third party library with it’s own autoloader. Yii’s guide has some documentation on how to tackle the situation but it doesn’t work out of the box for most of the people. The reason why integrating third party libraries with autoloaders in Yii isn’t as simple as integrating a non-autoloader library is that third party autoloaders conflict with Yii’s own autoloader.

In such a situation, you can use the code mentioned below and change the path/library as per your requirements in second line. You can use it anywhere in your code (most likely in controller) as needed.

Trick here is to temporarily unregister Yii’s autoload functionality before adding third party autoloader and then re-enabling Yii’s autoloader. You still need to include the vendors directory in your application’s main.php as shown in second code snippet above.

I am not sure if this works in Yii 2 as well, most likely it won’t since Yii 2 is a complete rewrite, but this certainly works in Yii 1.x releases.

My take on #GiveItUp (LPG Vs Parliament Canteen Subsidy Debate)

Standard
LP_gas_cilinder

Image courtesy – wikipedia.org

Government is asking citizens, those who can afford, to give up LPG subsidy voluntarily. Why? In 2013-2014, government spent nearly Rs. 40,000 Crores on LPG subsidy. Even if a small percentage of population gives up subsidy, it would result in considerable savings to the exchequer. And that would not only help reduce the fiscal deficit of our country but more importantly, will help the people in lower income category get cooking gas at subsidised rates. Continue reading