Who is at helm in a Start up?

Few days ago the news about top level shifts, followed by some top-level exits, in ‘the’ most prominent Indian startup captured headlines when the founders were stripped off of their CXO titles and their responsibilities were reduced to mere placeholder-roles akin to rubber stamps. They were replaced by an administrator appointed by the investors.

The founders still held the majority shares, including veto shares, their respective chairs at the board of directors and the right to vote. And that made many believe that they still held power & control.

The whistle blower troll circle, often referred to as the Startup L. Jackson(s) of India had this information at least a month ahead of its announcement. They kept on hinting towards the upcoming tsunami of layoffs, cost cuts and massive reorganizations. The keenest of the observers started making speculations.

But there was certain class of objectors who chose to turn deaf to all these noises. I had a spat with one such objector over the fact “who still holds the power here“.


A naive animal in an animal farm believes the breeder feeds them & hence will never kill them. This happens to people too. Or should we call them sheeple?

The Ship

Consider a startup as a ship, that left the pier with a limited supply of food & water & a mini livestock aboard (no, not Noah’s arc) and has to complete a 90-days’ journey across the Atlantic (no, not Niña, Pinta nor Santa María). Midway the ship hits a rock (no, not the Titanic). The captain’s damage assessment team did a survey and kept their assessment confidential to prevent undesirable panic among the sea-men. But they did not have to ability to prevent actions by individuals onboard.

Some could sense the threat, some couldn’t, and some decided to wait while some chose to believe that the threat was nonexistent.

The Rats

When a ship is about to sink, rats jump off the deck first and per the code of conduct, the ship’s captain is always the last.

It’s not bad to follow your survival instincts. It’s not bad to be a rat or follow one. Saving one’s life should be one’s top priority. There is no reward that can compensate loss of life. Better be a rat & survive than an audacious man on deck to die later miserably.

Proactive Rats

Some rats are wiser than the others, those who read the signs early & observe the symptoms, match the patterns and take action in right time. They are the pre-crastinators.

One among many such signs, one is M&A. At 31:48, Guy explains when a VC firm acknowledges your company as a loser company (say loser A) in their portfolio, they arrange your acquisition by another loser company B in their portfolio to save face.

Procrastinating Rats

Some rats are procrastinators. They are hesitant about jumping off. This hesitation may not be inherent to them. It might just occurs to them because of the the market situations. I mean, what would they do if they left the ship & boarded another which sank immediately after their arrival?

Now, you might complain – that’s totally hypothetical, stop cooking up stories. Well, ebay was shut 2 months ago and they’re recruiting & on boarding people until a week before they pulled the shutter.

So, these hesitant rats choose to take action when the moment finally arrives. They still manage to survive the situation because they remain prepared & well equipped to handle it.

The sheep and the suicidal lemmings

So, this startup had lost its first batch of rats who ran away elsewhere to save themselves from the big tide. But now it was left with the brain-dead lemmings, and the docile & gullible lot  – the sheep.

The lemmings have no ability to think. They just follow the one before them. The possibility of their survival depends entirely on their leader.

The sheep can foresee some danger approaching them. But instead of dealing with they, they decide to bury their heads in the sand & believe that nobody’s going to hurt them.

I’ll definitely appreciate if that’s self-confidence induced audacity.

But if that’s ignorance induced ostrich syndrome, then this needs to be stopped. Choosing to remain in a constant state of denial while overlooking the facts and the phenomena is a blatant insult to one’s conscience, that their emotions overpowered their ability to reason,  that they have shut their eyes and pretending that nobody’s watching them, that they can  no longer distinguish what’s reality and what’s delusion.

The start up laid off several of its staff including their head of products in June-July citing the obvious reasons – performance. Some employees took action and fled for security.

The startup is laying off some from its leadership team.

The threat is imminent. Of course, correlation may not imply causation always. But during the moments of crisis, being a bit pessimistic can be good. Your intuitions may not be accurate enough to help you out in need.

The problem with intuition is that people only remember when their intuition was right–truth be told, their intuition was probably wrong as often as right.

Guy Kawasaki, Art of Recruitment

When the news came, it captured the attention many. Budding entrepreneurs, graduates, engineers, buyers, sellers, economists and even the consumer base in India who had developed an emotional connection with the brand – everyone was curious what was going wrong. All of a sudden, the poster boys of Indian startups became the example of the biggest losers.

But it’s even more surprising to see that there are still people who believe that the तारणहार (Taranhar) will save them from the apocalypse. Good luck to them!

Guy Kawasaki: The Top 10 Mistakes of Entrepreneurs

Long back while dreaming about creating my own startup, I was reading, watching & stuffing myself with information from all sources and I happened to come across a brilliant talk by Guy Kawasaki where he explains the top ten mistakes by entrepreneurs, and at 23:30

Many many entrepreneurs believe as long as they and their buddies own 51% of the company they are in control of the company …

… but the truth is the moment you take outside money you have lost control of the company.

It never comes down to a vote 51 to 49.

This is not the US senate.

The moment you take external investment you’ve already sold your company to the highest bidder. You no longer remain the owner, but become a salaried (or non-salaried) employee of the company who has a mandate to meet the numbers & deliver on the promises.

The rights to vote, the seats at the board, or the percentage of ownership become irrelevant.

So who is at helm?

Can’t help you if you’re still unable to decide for yourself.



Redux forms: Scroll to form field containing error message

  • Redux forms v6.2+ provide you with an onSubmitFail callback when a validation fails in your form.
  • Add refs to all Field elements with name
  • Note: Without refs, this will not work at all.
  • Import the following function as a utility and bind it in your constructor.
  • Whenever there is an error, this scroll the page to the 1st element in the page containing errors.

import ReactDOM from 'react-dom';
 * Handles the errors received and determines the first element
 * containing the error as the 'key' element, so that,
 * it's positions can be determined
 * Scrolls the page that element to bring into visibility
 * And focuses on the element
 * Requires developers to use 'ref' attribute with 'name' in form fields
 * @param  {[object]} errors
 * @return {[undefined]}

export function handleSubmitFail(errors) {
    if (!this.refs) {
    const refsKeys = Object.keys(this.refs);
    const keys = Object.keys(errors);
    let key = null;
    let matchfound = false;

    refsKeys.filter(item => {
        if (keys.indexOf(item) > -1 && !matchfound) {
            key = item;
            matchfound = true;
            return false;
        } else { // eslint-disable-line no-else-return
            return true;

    this.targetNode = this.refs[key];

    if (this.targetNode) {
        const node = ReactDOM.findDOMNode(this.targetNode);
        const parentNode = ReactDOM.findDOMNode(this);
        const xy = node.getBoundingClientRect();
        this.x = xy.right + window.scrollX;
        this.y = xy.top + window.scrollY - 60;
        parentNode && parentNode.scrollTo && parentNode.scrollTo(this.x, this.y) || 
        (parentNode && parentNode.scrollTop && (parentNode.scrollTop = this.y) ) || 
        window && window.scrollTo(this.x, this.y); // eslint-disable-line no-unused-expressions

Update: The section below has been added as per the request of John, who made a comment requesting me to explain how to use this.

How to use it?

To use this handleSubmitFail event handler, we first need to save it somewhere. So, let’s save it under a `utils` directory.

Now, we need to import this method into each of our components. There might be other simpler ways than just writing the same code over-n-over again, but we won’t be getting into that right now.

After importing, we’ve to bind it with the component’s this lexicon in the constructor.

import React, { Component } from 'react';
import { reduxForm, propTypes } from 'redux-form';
import { connect } from 'react-redux';
import { handleSubmitFail } from 'utils/errorUtils';
import * from '../../../every/thing/else';

let onSubmitFailHandler = undefined;

 * Let's define some component here.
class SomeComponent extends Component {
    static propTypes = {
        onSubmit: React.PropTypes.func.isRequired,
        initialState: React.PropTypes.object.isRequired,
        onDiscard: React.PropTypes.func.isRequired,
        currentFormState: React.PropTypes.object

    constructor(props) {
        // this is where we bind the handleSubmitFail method
        // which we imported from the Utils directory
        onSubmitFailHandler = handleSubmitFail.bind(this);

    shouldComponentUpdate(nextProps) {
        if ((this.props.initialState !== nextProps.initialState) ||
            (this.props.currentFormState !== nextProps.currentFormState) ||
            (this.props.loading !== nextProps.loading)) {
            return true;
        return false;

    componentDidMount() {

    componentWillReceiveProps(nextProps) {
        // execute all methods you want to

    componentWillUnmount() {
        // ...

     * On submit calls onSubmit of redux form.
    handleSubmit = (form) => {

    render() {
        if (this.props.loading) {
            return ;

        return (
    <h1 className='form-heading'>Please fill up the Form:</h1>
    <form autoComplete={ 'off'}>
        <Field name='account_name' ref='account_name' component={Fields.AdvertiserNameField}/>
        <Fields.EmailField name='primary_email' ref='primary_email' />
        <Fields.PhoneField name='primary_phone' ref='primary_phone' />
        <Fields.CommunicationAddressField name='line_one' ref='line_one' />
</Paper> </SomeComponentChildElement> ); // JSX template goes here } } const formName = 'someComponentName'; export default connect(state => ({ initialValues: state.some.place.form.someComponent, initialState: state.some.place.form, loading: state.some.place.form.meta.someComponentLoading, currentFormState: state.form[formName] }), dispatch => ({ onSubmit: (form) => dispatch(handleSubmitForSomeComponent(form)), loadingSomeComponent () => dispatch(loadingSomeComponent()), loadedSomeComponent: () => dispatch(loadedSomeComponent()), handleUnmount: (form, isFormValid) => dispatch(handleSomeComponentUnmounted(form, isFormValid)) }))(reduxForm({ form: formName, validate, onSubmitFail: (errors) => { if (onSubmitFailHandler) { onSubmitFailHandler(errors); } else { throw new Error('No handlers found for redux-form submission failure! Look at http://redux-form.com/5.2.3/#/api/reduxForm?_k=nz53ec for more info.'); } } })(SomeComponent));

When I’m on Modafinil vs when I’m not on Modafinil

When I’m on Modafinil

  • I should prepare the strategy for creating great designs
  • I should organize mood boards, and should focus on creating themes and UI kits rather than jumping into design
  • I should investigate why t-engine is faster than vanilla nginx
  • I should find out if anyone else logged into my digital ocean VPS as the root user or not
  • I must find out the optimal way to isolate webpack from node to reduce the compile time
  • I must learn Kannada
  • I’ve heard people who learnt multiple languages had greater IQ
  • P V Narasimha Rao must have been great. He sent Vajpayee as a delegate to represent India once. That’s damn awesome.
  • There should be IQ level indicator in Facebook. You should ignore (or prevented from) engaging in comment-wars with people of lower IQs. I must create a chrome plugin that determines someone’s IQ and warns.

When I’m not on Modafinil

  • I should rather be at home. I focus better at home
  • The chirpy team next to me is very noisy & seems jobless. I can’t work in an environment like this.
  • I need coffee.
  • Enough for the day. Too noisy here. I should rather go home and sleep to get rid of the noise in my head.
  • It’s Wednesday. Because the noise levels are at peak.
  • I don’t know how to file IT returns yet. How’ll I manage a family?
  • The problem with open floor office designs is – you’ve no privacy. Joel Spolsky was right. Nobody wants to work in facebook because of their acre wide open floor office.
  • I need espresso. Double black eye.
  • Why people are so optimistic about their political leader and too cynical about who question the authority in this nation?
  • I’ve no cash. How’ll I manage a family?

webpack sucks, at least for now

Javascript is an interpreted language and by that I understand that when I hit the F5, I expect zero latency for the new script to appear in local dev environment.

When you take that away by introducing obnoxious compilers like webpack – that first needs to be told how to load, then it compiles, then concats before showing me the output, you’re already the subject of my fury.

The ‘wait time’ for compilation sucks

The reasons why I stayed all these years away from coffee script –

  1. I know how to write ‘good’ javascript and
  2. The compilation time – it sucks.

Let JS remain the interpreted language we all know and love. Don’t put your compiled language genius into it. You’re not welcome here – to the interpreted world.

Debugging is horror

you’ve to trace that line out. Imagine a project consisting of 100 small files with almost similar looking content that you concatenated and now clueless where exactly to hunt and debug.

It’s not uncommon – when you write derived components inherited from parent components, the siblings tend to look similar.

webpack – you’re a clutter builder and clarity killer. And, No. I’m not going to work in large files a.k.a monoliths just to support your existence.

Lack of build blocks

I came from an AngularJS Development environment, where I extensively used yeoman and that allows me to work on an index.html file locally which has references to locally kept css and JS.

That means we don’t have to wait for concat or compile before we hit the F5 or ctrl+r.

Plus, the library files from bower_components stay separate. In webpack, unfortunately, they become part of the compilation step.

Luckily, we’ve wiredep and usemin blocks for our rescue – which simplifies local development and gives great support for production builds.

Learn something from it. Your hotness may look tempting to fools and noobs. I ain’t one. Grow up.

Till then – happy hating.


And, I always believe there is no point in complaining, one must find a remedy. Following are some workarounds to reduce frustration:

Promises in jQuery: Simple Example

Problem Statement

  • You’ve a Master Form containing multiple child forms.
  • Child forms are submittable on their own, and have separate API end-points i.e. Child forms 1,2 & 3 will be processed by api1, api2 and api3 as services (say).
  • But Master form can only be submitted if
    • all of it’s inputs are valid
    • all inner forms are valid and have been submitted already
Multiple child forms with in a Master Form
Multiple child forms with in a Master Form

Solution Approach

Nested forms are not possible in HTML because a form can have only one action path.

So, ajax FTW.

Using Nested Ajax Calls

Nest successive ajax calls inside the success callbacks of the previous $.ajax  call and nest the final master form submission callback inside the last ajax request callback.

       ... //submit the master form after the last call is done

Click Here: To view Full Code


  • every request has to wait until the previous has finished i.e. 2nd ajax has to wait until the 1st request is resolved, and so on
  • If one of them fails, then all subsequent calls fail

Using Deferred Objects

Asynchronous requests are fired independently.$.ajax returns a promise object. Collect them in variables. The final callback will be triggered as soon as all of deferred objects are resolved in $.when(). 

Solution with deferred objects looks like:

var v1 = $.ajax1({ ... });
var v2 = $.ajax2({ ... });
var v3 = $.ajax3({ ... });
$.when( v1, v2, v3 ).done(function(){
  ...   //final submission of the form
...   //rest of your code
  • No Nesting
  • No Waiting per request
  • $.when will wait until all promises in arguments are resolved
  • .done( ) is fired when all promises are resolved – ideal place to pass the final callback

Click Here: To View Full Code

Code Snippet 1

  success: function( apiResponse1 ){
        success: function( apiResponse2 ){
              success: function( apiResponse3 ){
                  //Final ajax
            });//3rd ajax
      });//2nd ajax

Code Snippet 2

  api1 = $.ajax({
    url: "example.com/api1",
    success : function( response1 ){ isValid1 = response1.isValid; }

  api2 = $.ajax({
    url: "example.com/api2",
    success : function( response2 ){ isValid2 = response2.isValid; }

  api3 = $.ajax({
    url: "example.com/api3",
    success : function( response3 ){ isValid3 = response3.isValid; }

$.when( api1, api2, api3 ).done(function(){

      url: "example.com/finalSubmission",
      success : function(){
        ... //final call


call(‘me’); //weird

The Case : When a rookie corrupts my configuration in the Global Namespace

So, I was working with Namespaces. I was panicking over a situation when my configurations (set into the global namespace) could be overridden/deleted by any rookie who doesn’t use pipes e.g.

//my global configurations
(function() {
  this.myGlobalConfig = { ... };
  api = {
    init : fn.init.apply(this)
}.apply( Namespace || {} ) );
//after many lines of code, if the rookie writes
var Namespace = { ... }; //rookie missed the pipes here

The Case : When a rookie creates a global variable with the same name as the namespace

So, we let our rookie write anything. What the rook does is interesting:

var Namespace = 10; //say a number

Now, the question is: Will my module still work?
The answer is : Yes, except the APIs exposed to public.

Here is a hint why your module will still work without throwing any errors:

function foo () {
  return typeof this
foo.call({});      //"object"
foo.call(1);       //"object"
foo.call("oh no"); //"object"

foo.apply({});      //"object"
foo.apply(1);       //"object"
foo.apply("oh no"); //"object"


Javascript implicitly converts any primitive data type to its corresponding Object type when you use call or apply on it. To verify, you can do a typeof check inside the class (function) name.

Here is a little test to prove this:

function foo () {
  console.log(this instanceof Number , "Number");
  console.log(this instanceof String , "String");
  console.log(this instanceof Array , "Array");
  console.log(this instanceof Object , "Object");
  return typeof this

// false "Number"
// false "String"
// false "Array"
// true "Object"
// "object"

// true "Number"
// false "String"
// false "Array"
// true "Object"
// "object"

foo.call("oh no");
foo.apply("oh no");
// false "Number"
// true "String"
// false "Array"
// true "Object"
// "object"