Parallel Ajax request and session locking

Yesterday, I was running into a weird issue when I was making parallel ajax requests to my php server running CodeIgniter MVC framework. Let me explain: I had two controller methods A and B. Method A was executing a long action (io and network bound) and was updating database with its progress at regular intervals. Method B was retrieving this progress status from the database and presenting it in html format. I had setup the following jquery ajax calls 

a) A call to method A

b) A call to method B every 2 seconds. 

The idea was to update the UI with the results from method B while A is being performed. This way the user is cognizant of the progress of this long action. The issue I was running into was that method B never returned until method A was complete. When I investigated these requests in chrome I observed that request issued by method B was tagged as “pending” in chrome.

After much research I concluded that the issue was due to php session locks. PHP session doesn’t allow another script to run unless an existing script completes its execution. 

 

Solution: The solution is to explicitly close the PHP session after you are done with using the PHP session variables. In my case I closed the php session as soon as I entered method  A and re opened it at the end of method B. Note, you won’t be able to update any variables unless you open the session again. 

Advertisements

How to compare mongo ids?

Today, I was trying to compare two mongoids. I thought it would be really straightforward but it took me around 30-40 minutes to figure out how to compare two mongoids. You need to retrieve the “id” param of MongoId objects you wish to compare. Let’s assume user1 and user2 are two instances of MongoID class and you wish to compare the IDs of these two objects. This is how you do it.

if ($user1->{“$id”} == $user2->{“$id”} ) { …

do blah

}

Roommates and leases

Everyone knows that a bad roommate/roommates can make your life living hell. I have had my share of good and bad roommates. Some of my roommates have become life long friends while others I could care less about. As a variable in a computer program, a roommate has a certain lifetime. Mostly, it is the duration of the lease. If you have roommates of the later type you are bound by this written contract and the lease expiry date becomes the most important day of your life. You wait anxiously for this day and when it arrives you celebrate it as if its new year’s eve.

Now, if you are a student , your apartment is more like a revolving door. There is always someone moving in or out of it. In such a “high churn” environment, the existence of a lease is nothing more than a nuisance. The incoming roommates, especially if they are about to graduate, make every effort  to bypass this written contract. They insist on “verbal” lease as it is the most convenient option for them. In some situations, when an immediate roommate vacancy needs to be filled and/or incoming (graduating) roommates are so called “good friends”, such verbal leases are constructed as it is a “win-win” situation for both participating parties at that moment.  This “win-win” situation quickly turns into “win-lose” situation for existing roommates when the new roommates move out  without sufficient notice or suitable replacement. Remember, the people not on the lease are not legally liable for the rent. They are only morally liable and when it comes to money morality tends to take a back seat.

According to my observation and experience, this situation arises more often than not in the ‘student’ environments. So, How do you avoid them?  Here are some steps

a) Always insist that anyone staying in your apartment have to be on lease.

b) Make anyone moving out legally liable for rent for the remaining duration of the lease.  If he/she is not in agreement, initiate a legal action through the leasing office.

c)   A “roommate replacement” is an acceptable solution as long as following conditions are met,

  • The existing roommates are comfortable with the new replacement roommate.
  • The new roommate agrees to be on the lease.

d) If you are the one moving out and you find an acceptable replacement roommate, make sure that ,

  • The replacement roommate signs the lease as soon as possible.
  • Collect deposit (if any) from him/her.

The Vac Pack Shack – Critique of UCF’s business plan competitions

In Feb, I (along with my co founders) attended UCF’s elevator pitch competition organized by Center of Entrepreneurship and Innovation (CEI) to pitch our company Gotootie Inc. 13 other teams participated in the competition.The panel of judges consisted of 4 people (UCF alumni) from various backgrounds. If I recollect correctly, their backgrounds consisted of real estate, insurance and technology staffing. Unfortunately, none of them had a pure technology background (a person working/owning a technology staffing company does not qualify him/her to be of ‘technology’ background). As the business plan competitions are never marketed strongly in the science and technology departments by CEI, ours was the only team having any relations with science and technology department.

The judges selected 4 winners. First position went to company called ‘Vac Pack Shack’. It is a niche e-commerce company that sells ‘zip lock’ like bags in customizable sizes. Second position went to a water bottle company (I fail to recall its name). They manufacture water bottles,as a self contained units, that generates clean drinking water from dirty water. Obviously, the target segment is the set of people who do not have access to clean drinking water. There were around 5 information technology focused companies and as expected none of them made it to the top 4. According to me , this is a direct result of the panel lacking necessary technology background. The panel simply did not understand the technology businesses. For example, they did not even question the intellectual property or the technology related to the water bottle. Any panel with technology background could have raised these questions as they are extremely important to the viability of the business. All the other stuff, like the structure of the actual pitch, is irrelevant if your technology cannot be proven or protected.

Over last couple of years, I have had various conversations with people connected to CEI. From those conversations, I gather that one of the main aims of CEI is to foster entrepreneurship in the science and technology (S & T) departments. This is very important and relevant goal for CEI as UCF has very strong science and technology (School of EECS, Biomedical, CREOL, Industrial etc etc) departments but they lack entrepreneurial focus. These schools and departments are definitely stronger and well known than College of Business. If this is the case, why did the panel of judges, not contain a single ‘technology’ judge. Thus, I believe there is a major disconnect between CEI aims and their actions. One of the reasons could be CEI’s lack of contacts (or lack of clout) in the technology industry. Even though, Orlando is not a technology hub there are few respectable technology companies in the Orlando area (Oracle, Symantec , EA sports, Harris Corporation, etc etc.) .I guess it wont be too difficult to tap into these resources for such competitions.

The judges also performed poorly. They acted as conservative investors. They only picked businesses with mature business models that they could understand. How difficult is it to understand the business models of ‘Vac Pack Shack’ and the water bottle company? I guess, not too difficult. The judges of academic business plan competitions are meant to act as maverick, early stage, high risk investors. This helps to promote unconventional business ideas which otherwise would not get the required exposure. The judges acted in the exact opposite direction and this showed when they selected the winners. We were so disillusioned by this that we decided against entering ‘Joust’ which is the annual business plan competition. Our instincts were spot on as the ‘Vac Pack Shack’ went on to win the business plan competition.

As long as the judging focus for the UCF business plan competitions remains on very mature and easy to understand business models, like Vac Pack Shack, and winners are selected based on these criteria, UCF will never foster entrepreneurship in the S & T departments.

a) heavily market their competitions in the science and technology departments.
b) Make sure judges have necessary technology backgrounds.
c) develop strong relationships with local technology companies.
d) Make entrepreneurship seminars compulsory, much like technical EECS seminars.
e) Fund a student run technology entrepreneurship organization.

Can entrepreneurship be taught?

Before, answering the above question, let us try to answer another question, “Can you teach someone to fight for a cause?”.The answer, in my opinion, is big emphatic “No”. Who taught Mahatma Gandhi to fight for India’s Independence? I hope you agree with me when I say that no one really taught him to pick this cause and fight for it, unto death. Although, you can’t teach an individual to pick a cause and fight for it, you certainly can inspire him/her to do so.

I consider entrepreneurship to be a cause, a cause to solve a certain problem that you are passionate about,a cause to create jobs, a cause to create wealth, a cause to stimulate the economy.  Now, How do you teach students to take up this cause? Well, you can’t.Thus, in my opinion, entrepreneurship can never be taught in a traditional class setting. The entrepreneurship classes offered by most business schools can certainly teach some useful tools, but, an entrepreneur does not need them from the get go. He/She is better off learning them on demand.

To create entrepreneurs, universities/colleges should brand entrepreneurship as a “cool” and “exciting” cause and inspire all of its students to be associated with it. They should create an agent on campus that continuously draws students to this cause and spreads the “entrepreneurship” message that

  1. It is “ok” to take high risks.
  2. It is “ok” to be overtly optimist.
  3. It is “ok” not to enter the traditional 9 to 5 workforce.

Also,one of the most effective ways of nurturing entrepreneurship on campus, is to hire faculties that are entrepreneurs and not just entrepreneurial.

In short, to create entrepreneurs, universities/colleges should stop teaching (it doesn’t work anyways) and start inspiring future entrepreneurs.