free html hit counter
Posted on: Tuesday, November 1, 2016 by Rajiv Popat

Getting Started With Aurelia And Type-Script on Visual Studio 2015

If you’re interested in and working with Javascript frameworks, you’ve probably heard of Aurelia by now. It’s a compelling competitor to frameworks like Angular and React.  While getting started with Aurelia itself seems pretty straight forward, getting Aurelia working with Type-Script and making it all work Visual Studio 2015 has it’s own share of hiccups.

The aurelia team provides starter projects that they call skeletons that you can download and get up and running really quickly. However when I tried using them, the skeletons seemed to have issues which were both time-consuming and frustrating to resolve. Even the skeleton that was supposed to run with .NET MVC (and had a “.sln” solution file) would not even compile without errors. And these skeletons come with a lot more than what you would like have when you are just trying to get an initial hold of Aurelia and type-script. This left me with no other options but to star fresh and create my own basic skeleton where I can try out different Aurelia features.

If you’ve tried to get started with Aurelia + Typescript and you are a .NET programmer who lives inside Visual Studio, the goal of this post is to get you up and running with Aurelia and Typescript inside Visual Studio 2015.

To being with you’re going to need Typescript working inside your Visual Studio 2015. The simplest way I’ve found to do this is, just un-install older versions of Visual Studio 2015 and install Visual Studio 2015 Update 3 from scratch. You could use that link, but then if you have an MSDN subscription you are better of downloading an offline ISO from there and using that, which is what I did.  Initially, I tried in place update of Visual Studio 2015, and the installer kept crashing for some reason (this of-course could be because of the fact that I was on a weak Wi-Fi).  The MSDN ISO (a 7 GB download) worked smoothly after an uninstall of my existing visual studio; followed by a fresh install.

With Visual Studio 2015 Update 3 (with Core 1) loaded, you’re also going to need Typescript support inside Visual Studio so your Typescript files are compiled and converted to JS files each time you save them. To do that you can grab the Visual Studio Typescript plugin from here and install that. You will also need Node Package Manager (NPM) working on your machine and the simplest way to do that is download and get  Node JS installed on your machine.

With that done we’re ready to start our first hello world project with Typescript + Aurelia.

As I said before, the easiest way to do this would have been to download and use the skeletons, but given that the skeleton’s provided by Aurelia team didn’t work for me;  I was left with no option but to build my Aurelia app from hand and get started. Honestly, building your first app by hand actually works out better because it gets you a fresh new insight into many underlying concepts that you will typically not have to pickup if you use a ready made skeleton instead.

Since we’re going to be working with Visual Studio 2015 as our IDE of choice, let’s go and create a blank ASP.NET Web Development project inside Visual Studio in a folder of your choice. Open the solution file and keep the solution open in Visual Studio as you proceed with the below.

Once the project is created start command prompt and go to the specific location where you created the project. Note: go inside the project folder (not the folder with contains the .sln file – but the one that has your web.config file.):

Once there start by typing in the following commands:

npm install jspm
jspm init

JSPM is the JavaScript Package Manager which let’s you fetch and use various  Javascript modules you will need to get started with Aurelia. In the above diagram we switch to the project folder (shown in the screenshot + code snippet),  do a NPM install of JSPM which fetches JSPM on your machine. Once there we initialize jspm in our project folder (jspm init) where it will create new project asking you basic questions:

We select the default answer by just hitting enter, except for picking the Transpiler, where we will use TypeScript instead of the default Transpiler JSPM uses (babel).

Once that is done we continue with rest of the defaults and finish our “jspm init”.  We then install the required underlying frameworks in our project by doing:

jspm install aurelia-framework aurelia-bootstrapper bootstrap

This should pull all files pertaining to Aurelia framework, the aurelia bootstrapper and the bootstrap framework (which are the very basic things we need to start a simple web application with Aurelia and Typescript). If all goes well your folder structure should look like this inside Visual Studio with “Show All Files” selected in Solution Explorer:

We now need to start writing code for our project. The first thing we do is right click the config.js file in the solution explorer and say “Include in Project”.

Once done we open the file and add the highlighted line :

This tells the Transpiler to look for code in the “src” folder. Of course we don’t have that folder in our solution so we create that by right click solution explorer and clicking create folder and adding the src folder. Now we have a place where we will write our Aurelia code. But any web-server that we will also use to host the code will need a startup file to begin running the application – which usually is index.html. So let’s code the following index.html by hand:

<!DOCTYPE html>
  <body aurelia-app>
    <script src="jspm_packages/system.js"></script>
    <script src="config.js"></script>

This is a simple standard index.html file most Aurelia applications will typically need. We are adding two JS files that aurelia needs. The first is system.js and the second is where our configuration is stored (config.js). We then use System.import (from system.js) to import the aurelia-bootstrapper.

Also note the “aurelia-app” tag in body. A few important pieces are getting connected in the above code and aurelia is using convention to connect the pieces. The index.html tells aurelia to use the config.js file. And as we’ve seen before, the line we added in config.js tells aurelia that the custom aurelia code would be in the “src” folder. The “aurelia-app” tells aurelia to be default look for “app.js” as an entry point. Note: we haven’t specified app.js – but the aureila-app tag itself (by convention) tells aurelia to use app.js by default. You can of-course override the convention but that’s for another post. Right now, let’s just create a app.js in the source folder.

We could drop an app.js file inside source, but remember we are planning on using TypeScript throughout the project, so instead of an app.js, we will use “app.ts”. We will work on the typescript file (app.ts) and let Visual Studio to generate the .js fie each time we save the “.ts” file. So let’s right click “src” folder and add a Typescript file and call it “app.ts”.  Because typescript provides added intelligence and compile time validations, it needs what we call typing files which allow visual studio to validate your TS code. Which is why Visual Studio will ask you this:

Going ahead we will grab out typing files manually so say no to the above for now and let’s proceed. We’re going to talk more about typings later in this post.

In your blank app.ts add the following lines:

export class App
    Message: string;
        this.Message = 'Hello World';

Note in the above code, we have a simple type-script class (this will translate to a JS function) and string Variable called Message. In the constructor we add a default value to the field. This app.ts, will get translated to app.js when we save it and will act as a view-model. Now that we have a “View Model” let’s go ahead and make a View. Aurelia view are simple HTML pages surrounded by a template tag. So inside “src” folder let’s add a new app.html and add the following lines:

    Message received from View-Model: ${Message}

The Message that we set in the View-Model should now flow to the view and when you compile and run the project at it’s root, you should now see:

Congratulations! You have your first Aurelia project with TypeScript running now. Now let’s do something more meaningful and try to create a screen to add customers to a List of Customers. To do that let’s start by making a Customer class by adding a “Customer.ts”. For now let’s modify the blank Customer Class so that it has a CustomerName attribute and looks like this:

export class Customer
    CustomerName: string;
    public constructor()

We will now need to go ahead and use the Customer inside app.ts and then create a function inside app.js that allows us to create a customer to the list of customers. To do that we modify our app.ts:

import { Customer } from './Customer';
export class App
    CurrentCustomer: Customer;
    Customers = new Array<Customer>();

        if (this.CurrentCustomer)
            this.CurrentCustomer = new Customer();

In the above code we use Import to import the Customer class into our App class so that we can use it in our code. Then we create an array of Customers (which will hold a list of customers) and a specific Customer (which the user will add using the UI). The “addCustomer” method adds the current customer to the list. To put sense into all of this let’s create a UI front end which has a textbox, and button called “Add Customer” which adds the customer whose name you type in the textbox to a List of customers which is re-presented by a “UL”. The final view (index.html) looks like this:

    <form submit.trigger="addCustomer()">
        <input type="text" value.bind="CurrentCustomer.CustomerName" />
        <button type="submit">
            Add Customer
            <li repeat.for="Customer of Customers">

Notice that in the code above I have a form whose submit triggers the addCustomer method which we write in our View-Model. There is a textbox which we “bind” to the CustomerName of the Current Customer, which again is defined in our view model. We have a simple submit button and a UL where the LI’s repeat for every Customer in the “Customers” array which is defined in our ViewModel. The UI looks like this:

As we type the name of the customer and click the add button the customers get added to the list:

And we can do this with multiple customers:

The binding of the textbox with the CurrentCustomer.CustomerName ensures that the value passes from the view to the view-model. Each Time addCustomer is called, we create a new Customer object and hence the textbox blanks out after the existing customer is added to “Customers” array which is bound to the UL using a “repeat.for” loop.

So far so good. Everything we’ve done thus far, compiles, builds and runs.

However as you start going into deeper Aurelia, you will realize that you will need to use more complex concepts like Dependency injection (where you would like to inject services into your view-models). The start project we have created works but isn’t fully ready to handle imports because we have the typing files missing. Remember we said we’ll discuss typings later in this post? This is the part where we now need to address typings to move ahead.

To virtually use any advanced feature in aurelia you will have to import the aurelia framework in your code. For example if you want to use the dependency injection of aurelia, your code to do so would look like this:

import { inject } from 'aurelia-framework';

Put that code in your app.ts and you’ll immediately realize that visual studio starts complaining:

And this is because Visual Studio knows nothing about the Aurelia-framework even though we had done a “jspm install aurelia-framework” right when we started. We had done the install with the command prompt using jspm but visual studio (and typescript) still require typing files for aurelia framework before they let you import specific components of the framework inside your TS files.  The simplest way to grab Typing files is to add a “typings.json” file in your project root and add the following lines to it:

  "name": "AureliaHelloWorld",
  "dependencies": {
    "aurelia-binding": "github:aurelia/binding",
    "aurelia-bootstrapper": "github:aurelia/bootstrapper",
    "aurelia-dependency-injection": "github:aurelia/dependency-injection",
    "aurelia-event-aggregator": "github:aurelia/event-aggregator",
    "aurelia-fetch-client": "github:aurelia/fetch-client",
    "aurelia-framework": "github:aurelia/framework",
    "aurelia-history": "github:aurelia/history",
    "aurelia-history-browser": "github:aurelia/history-browser",
    "aurelia-loader": "github:aurelia/loader",
    "aurelia-logging": "github:aurelia/logging",
    "aurelia-logging-console": "github:aurelia/logging-console",
    "aurelia-metadata": "github:aurelia/metadata",
    "aurelia-pal": "github:aurelia/pal",
    "aurelia-pal-browser": "github:aurelia/pal-browser",
    "aurelia-path": "github:aurelia/path",
    "aurelia-polyfills": "github:aurelia/polyfills",
    "aurelia-route-recognizer": "github:aurelia/route-recognizer",
    "aurelia-router": "github:aurelia/router",
    "aurelia-task-queue": "github:aurelia/task-queue",
    "aurelia-templating": "github:aurelia/templating",
    "aurelia-templating-binding": "github:aurelia/templating-binding",
    "aurelia-templating-resources": "github:aurelia/templating-resources",
    "aurelia-templating-router": "github:aurelia/templating-router"
  "globalDevDependencies": {
    "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
    "aurelia-protractor": "github:aurelia/typings/dist/aurelia-protractor.d.ts",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
  "globalDependencies": {
    "whatwg-fetch": "registry:dt/whatwg-fetch#0.0.0+20160524142046"

This will provide details of practically all aurelia typing files we are going to need for now and future. Once you have created this file and saved it go to command prompt, navigate to the folder that has the typings.json file (i.e. same folder as the one which holds your web.config) and type:

npm install typings –g

This will install the typings module globally. Now to grab relevant typing files based on your typings.json type:

typings install

Now we’ve fetched typing files but Visual Studio is still blissfully unaware about the fact that we’ve pulled the typings. You should also see the “typings” folder in your source explorer. However To make Visual Studio aware of the typings, we will need to add a typing definition file inside our source folder – the one which our Transpiler is watching. We can call this file anything as long as it has a “d.ts” extension but for now we’ll call “main.d.ts” and will place it inside the src folder. If you notice inside the typings folder you realize that is already has a typing definition file called “index.d.ts” – and it references all the necessary aurelia files;  so if our “main.d.ts” just references that file we should be done. Let’s go to our newly created blank “main.d.ts” (inside the src folder) and add this line:

/// <reference path="../typings/index.d.ts" />

With this done we now have the typings referenced properly and visual studio should stop throwing “cannot find module ‘aurelia-framework’.” error and that specific error should get fixed. However now when you fire a build you should see dozens of these two errors:

Build:Cannot find name 'Promise'.
Build:Cannot find name 'Map'.

This is because Aurelia typings internally use promise and collections. To fix this error we can use the Nuget package manager inside visual studio and install Typescript definition for ES6 promise and collections. The command to do that (inside Visual Studio Nu-get package manager) is:

Install-Package es6-promise.TypeScript.DefinitelyTyped

Install-Package es6-collections.TypeScript.DefinitelyTyped

Once you do that and once typings for promise and collections are installed your build should compile successfully. However, if you start using advanced features like dependency injection you will encounter some more build errors. For example, let’s modify your “app.ts” to use dependency injection:

import { Customer } from './Customer';
import { inject } from 'aurelia-framework';

export class App
    CurrentCustomer: Customer;
    Customers = new Array<Customer>();

        if (this.CurrentCustomer)
            this.CurrentCustomer = new Customer();

Notice the lines in bold which are using out of the box dependency injection of aurelia. In other words, aurelia automatically creates an object of Customer class and pushes it in the constructor. However the moment you actually do this and hit a build you should see compilation error:

Build:Experimental support for decorators is a feature that is subject
to change in a future release.

Set the 'experimentalDecorators' option to remove this warning.

To Overcome this error you will need add a new tsconfig.json in your project root and add the following lines to it:

  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "experimentalDecorators": true
  "exclude": [


The experimentalDecorators value of true ensures decorators like inject are allowed. Exclude on node_modules and jspm_packages ensures that the typescript compiler excludes those when it fires a build. Fire a build now and your build should fire successfully.  Run your code and it should just as before because we aren’t doing anything in particular with dependency injection here. In fact it’s actually a bad example of dependency injection but I included it in this post because the post covers the setup of a starter project that let’s you try out and learn everything that aurelia has to offer while using it with Typescript, inside Visual Studio 2015, so adding a right “tsconfig.json” and getting the typings upfront is a good idea (even if you are not using dependency injection or other advanced aurelia concepts).

I honestly believe that while the aurelia team is doing an amazing job documentation and videos of aurelia itself, but mixing aurelia with type-script and getting it all to run on visual studio 2015 can turn out to be a bit daunting for someone who is starting out his aurelia + typescript journey because there is no single place to get started. It would be really nice to not have to go through so many steps to just set up a basic development project where you can try out and learn features aurelia (with Typescript) has to offer, while working inside visual studio.

I know you can create projects using Aurelia CLI tools but even those had the similar typings related issues that I highlighted in this post. And getting those to work was an equally daunting task. Now that I have been working in aurelia for a few days, I can take a skeleton and make that work too, but as far as I am concerned, the learning curve to get into aurelia itself has been much lower than the learning curve required to get into aurelia with typescript and get it all to work inside visual studio. All I can do is hope that the Aurelia team builds some more documentation around getting started with Aurelia + Typescript. In the meantime, this post you get you on your way.

posted on Tuesday, November 1, 2016 4:03:18 PM UTC by Rajiv Popat  #    Comments [3]
Posted on: Sunday, October 23, 2016 by Rajiv Popat

52 Book Challenge (Books 8 to 21)

In 2016 I took up the 52 book challenge as a Marathon for my mind. My idea was to read a book a week and write about my progress on this blog. 2016 has been one busy year and I may not have been able to live up to my original expectations but I’ve been lucky enough to have taken time out during my commutes and weekends to sit and enjoy the company of a book every now and then.

I’ve written a review on seven of the books that I’ve read and really like this year but obviously I’ve been reading more. Here is a comprehensive list of all books I’ve finished cover to cover this year (The First Seven are in older posts, which is why this list starts from 8):


  1. The Practicing Mind: An averagely good book that talks about the power and benefits of focused practice. What I liked about the book was it’s basic message but the book lacks story telling and also lacks sufficient science leaving it in the murky territory of a typical self help book. Not that there is anything wrong with typical self help books, but not something I enjoy reading. I’d give it a 3 / 5.
  2. You are your own gym: Bodyweight training was how I started my fitness journey. As a nerd, any book that is focused on body weight training attracts me even today. There is something liberating about not having to depend on gyms, weights and machines to remain healthy. Being able to workout in a hotel room when you are travelling and not using travel as a reason to skip your workout is very empowering too. Written by an author who has trained special forces to be healthier and functional on field, the book has not just workouts but ideas and concepts every person who is into healthy life-style should read and understand. More than just a book, it’s a program that also has an accompanying app that you can download free and then buy if you like. I’d give this program (book + app) a 4 / 5 but don’t expect it to give you any magical gains, unless you have the consistency to stick to the program.
  3. The Tao of Pooh: I’ve always wanted to read philosophy outside the Indian and western philosophies and if there is one book that does an amazing job of introducing you to Taoism it is this book. It’s funny, it’s witty and it’s deep. One of the few books that prove that your writing doesn’t have to be complex to be deeply philosophical. And of course, who can not love Pooh? :) – A 4/5!
  4. Go for No – This is one of the few books this year that did not impress me. The central premise is fine – As a sales person, if you aim for yes’es in your sales call you are at an disadvantage. Every no you hear puts you down and demotivates you. But if you ‘Go for No’ and start your day by aiming for X number of NO’s every day, then you are motivated to keep calling even when you hear a no, because you are moving ahead towards your goal of X no’s. Every yes is a pleasant surprise and pushes you even harder. There are pages and pages of weird time travel based fiction where the protagonist falls on a golf course, hurts himself in the head, time travels and meets his own future self who teaches him the lesson of going for no’s. The book is a little too strange for my taste and what put me off about the book is that the only teacher the protagonist finds even in his own fictional world, is his very own hypothetical future self. The central premise is good but what could have been conveyed in one paragraph or a small readable blog post was stretched to an agonizingly long book with meaningless fluff and crazy fiction which was completely not required (and maybe even detrimental) for spreading the actual message. A 2/5.
  5. Naked Statistics: I haven’t read a book on Math since I finished my college and when I stumbled into this one, I saw it as a good opportunity to brush up on a subject that I never fully grasped in school. The book just blew me away in the way it describes some of the concepts of statistics that I studied in school but never really understood. From the difference between mean, median and mode, to topics like co-relation, the book covers each topic from a real life practical standpoint. It then touches the math side of each topic where the author takes very real simple examples to explain the complexities. The goal is to develop an intuitive understanding of some of the most used mathematical and statistical concepts and the book does indeed do an amazing job at it. A 4/5.
  6. Deep Work: Cal Newport as an author gained my attention with his book ‘So Good They Can’t Ignore You’ where he argued that passion is overrated. In this book he talks about the power and the importance of focused deep work in any creative person’s life. The book cites real examples of folks who go really far to cut themselves off distractions. The book is inspirational and the writing style is pretty good but there are not a lot of real unique ideas in this book that stick with you for life. A fascinating read though to understand how fragmented and distracted our lives today have really become. I’d give it a 4 / 5.
  7. Nudge: Written in the same tone of Switch(which I reviewed earlier) the book covers the topic of choice architecture in much more theory with many more examples. Though a lot of material in this book is very similar to  Switch, it covers a vast variety of topics going from designing toilets that encourage cleanliness to Libertarian paternalism in the world of nutrition. The tone of the book is very research oriented and factual with very little or virtually no self help advice which is what I love about the book. I would give this a 4 / 5. 
  8. Focus: The Hidden Driver for Excellence – From how a house detective scans a huge store full of people, focuses on small tell-tell signs and picks shoplifters; to the science of willpower and the understanding of the famous 10000 hour rule popularized by Malcolm Gladwell, the book covers a lot of ground but provides very little real life tools or frameworks to increase your attention. A good read especially if you enjoy books on Psychology but again, if you’ve read a few books on neuroscience and psychology you will not find a lot of new ideas in this book. I rate this a 3 / 5.  
  9. Eat and Run: After reading born to run when I came across Scott Jurek’s (who was one of the primary real life characters of Born to Run) personal biography, I needed no special nudes to pick it up. Scott is indeed as good a writer / storyteller as he is a runner. A intricately woven collection of experiences resulting out of the  races he has run, experiences he has been through and the life he has lived make the book a fascinating read. Scott’s own character, his vegan diet and his outlook on life is an icing on the cake. Again, a must read for anyone who wants to experience real-life story telling that is much more fascinating than fiction.  A 5/5.
  10. One Up on Wall Street: Maybe it’s my experience with banking software or the fact that I come from a family that has done business for five generations, I’ve always invested a part of my salary in long term stable investments and have been fairly lucky with these investments. When I saw this book by Peter Lynch,  a respected fund manager, I seized the opportunity of learning from a master investor. What’s amazing about this book is that it covers the basic technicalities of investing (things like the PE ratio, value investing etc.) and then jumps into the art of investing. Do you invest in companies which have rich amazing offices or do you buy stocks of companies where a bunch of hard working folks are working in a cramped office in a non-expensive corner of the city? Do you keep your eyes open when you see a real life consumer product in your local supermarket and place your bets by investing on the company before the financial experts of the world start giving positive reviews to the stocks of that company? In a predatory world of bulls, bears, computerized flash trading and deception Peter provides hope to the individual investor and shows them how they can use their local insights to get a one up on wall-street. A 4/5. 
  11. Sleep Smarter: As a nerd who lives an extremely irregular life as far as sleeping habits are concerned, when I bumped into Sleep Smarter I knew this was my chance to bring about some serious change into my life. The book was a collection articles which describe how big an issue sleep deprivation is and then moves into some real pragmatic tips that you can use today to improve your sleep. For example, avoid screen time at-least a few hours before sleep and if you must, install a special app that dims out light on your phone. How temperature effects your sleep, how the clothes you wear have an impact on your sleep and above all, how to make real lasting changes to your sleeping habits. This is not a book that everyone might appreciate but given my love hate relationship with sleep and the fact that I am a night owl who is also fascinated by the idea of waking up before the sun rises, the book was an extremely good read for me. I would give this 4/5.  
  12. Total Money Makeover: Dave Ramsey is one of the few guys in the world of personal finance whose advice I’ve incorporated in my own life and have benefitted HUGELY when it comes to my finances. I read this book early this year (in fact it was one of the first few books I read this year) and the book had one of the deepest influences on my financial life than any other book. I’ve adapted some of Dave’s ideas described in this book and have increased my savings 3X and am really close to becoming completely debt free. The book is an awesome read for everyone who has any debt, doesn’t keep a written monthly budget and doesn’t record every single transaction of his / her life. From busting popular myths about home loans, student loans, credit cards and car loans, Dave takes a slightly confrontational tone in this book but the tone serves it’s purpose of shaking you out of your dream world and brings you face to face with the dark reality of any debt and how that cripples your financial life. I’d give this book a 5 / 5 and the respect it deserves. If you have respect for money you should read this book. If you are a nerd who struggles with managing money, you have to read this book.   
  13. Originals: This book by far is one of the most ‘original’ books I’ve read on creativity. The book just demolishes every single conventional wisdom on creativity. Entrepreneurs are bold; WRONG. Entrepreneurs take chances and risks; WRONG. Most entrepreneurs are sure of their ideas and their vision: WRONG. Most startups are formed by people who are in their early thirties: WRONG. You need to quit your job if you want to form a startup and have conviction and belief in your idea: WRONG. Every single idea or non-scientific random self-help wisdom on creativity and entrepreneurship that you hear about so much these days will be shredded into tiny threads and blown off after you read this book. The book personally gives me validation that I’ve been seeking for a very long time but haven’t found anywhere else in the world. After reading this book all I can do is hope that more and more authors do responsible research like Adam Grant did for this book rather than parroting stupid self help catch words like – ‘passion’, ‘take the plunge’ and the ridiculous – ‘you can do it!’. No wonder this book has an almost 5 star rating on Amazon and is a breath of fresh air in all the books of business and creativity I’ve read thus far. I would rate it a big fat 5 / 5 and if you were going to read one book on creativity or if you were thinking of doing anything creative with your life, I would advice you to grab a copy of this book and read it cover to cover.   
  14. Mini Habits: Having difficulties working out? Why not start with just 1 push up a day? Sounds ridiculous? Try it and before you know it, you’ll be doing 100 a day in a couple of months. And if you don’t, well you can still do one and maintain your habit. The idea is ridiculous. In fact it’s so ridiculous it actually works! The premise behind this book? Our brain often makes an unpleasant activity which is good for us (like working out, eating vegetables) seem so difficult that we don’t even start. But what if we tricked our brain by saying, I’m just going to do one push-up or eat a tiny 1/2 inch slice of broccoli every day? There is very little resistance from your brain because the habit is so tiny. Once you start your brain sees it wasn’t that bad and naturally does more.   If it doesn’t; don’t push it – just do a pushup and you’re done. Which gives your brain no reason to resist. If you do more, you feel happy and encouraged. If you don’t you are not traumatized by the guilt of not living up to self-commitments and can still feel proud about finishing your commitment. It’s a small book, very to the point and a very interesting and practical way of hacking your own brain – which by the way, is a topic very near and dear to my heart. Definitely a 4 / 5.

I’ve obviously not been reading as much as I wanted to and probably will not make it to book 53 by the end of the year, but the challenge has indeed opened me up to new books, new ideas and introduced me to  topics I always wanted to read about. Net-Net it’s been fun so far and I hope I can read a few more interesting books before the end of the year.

posted on Sunday, October 23, 2016 11:48:22 AM UTC by Rajiv Popat  #    Comments [0]
Posted on: Saturday, October 8, 2016 by Rajiv Popat

Practical IoT Projects for Regular Nerds - Part 1.

There have been a lot of conversations around IoT lately. As someone who has done his major in accounting and as someone who builds business and financial applications for a living, I had a lot of excitement and some reservations about starting on my IoT journey. I mean I am just a regular nerd without any electronics background. Should I be playing with Microcontrollers and live current? After a few weeks, I’m happy to announce that the journey has been fun and I think it has been a journey worth sharing with you.

The basic underlying idea is to control things over the internet and hence the need for a programmable chip or a microcontroller - a small tiny independent board with a programmable chip that can run code in an infinite loop. The code controls the chip and the chip controls the devices or things it is connected to.

The “control” in the microcontroller can be as simple as turning a LED on / off or something as complex as building a smart home, with lights, fans, entertainment systems and water pumps controlled using your code.

Most articles and you-tube IoT examples out there are either way too complex involving complex circuits and code, or way too simplistic and impractical where someone shows you how to make a LED blink  with your code; which fortunately is a good start; but unfortunately does not allow you to anything practical with your microcontroller, which then puts your micro-controller in the same category as your gym membership - something you own but don’t actually use.

My goal with this series of posts, is to get started on IoT and provide enough insight on the topic to enable you to build something real and practical with it. The goal is also to take you to a point where IoT goes from yet another buzzword that electronics guys should be concerned about, to a practical, real, affordable and simple tool that you can use to build useful projects with.

In the first post we’ll cover some very basic concepts around the Arduino chipset (which is the micro-controller we are going to use for our IoT experiments) and write some basic code that runs on the chipset.

In the posts that follow we will attach some interesting modules to Arduino and write code to control these modules. Going ahead, we’ll get these modules and the microcontroller connected to your home Wifi and we’ll show you how you can control the microcontroller (and the modules connected to it) over the internet; and we’ll finally move on to working with real live electrical devices like, light bulbs and fans and control those with code.

All circuits we build in the process will be open sourced. All code we write in this process will also be on open sourced and  will be posted here on this blog for you to use.

When I started with my IoT journey a few weeks ago, I knew nothing about physics (or electronics) other than some basics I had picked up in high school, most of which I had never paid any attention to or had forgotten over time. Long story short, I’m just a regular nerd who writes business applications / CRUD screens for a living  and hence the series of these posts doesn’t require you to know physics or electronics to start. You will need to go out and buy a couple of cheap gadgets if you want to try some of these examples yourself but your overall investment will be less than 25 dollars.

And as a final disclaimer, I have never officially studied electronics so everything I write about here, is just a regular nerd trying to connect wires and have some fun. If something explodes (or if you cook a chipset or two) the responsibility is all yours!

Sounds good? Let's begin.

To start playing around with IoT we’re going to write code that controls devices so you’ll have to shell out some money and buy some basic devices. Even though there are platforms like the raspberry pi which make IoT much simpler, let’s start with buying a much cheaper micro controller which actually gets you a deeper understanding of the circuits you will be making, will make a smaller hole in your pocket and will help you stay away from having to run and entire Linux clone on your microprocessor like Raspberry Pi does.

Here are a few things you may want to go out and buy if you want to follow along:

  1. An Arduino UNO chipset - You can buy the original one or a cheap clone. I got one from amazon at about 7$.
  2. A Breadboard - so that you can connect wires and devices together without needing soldering equipment. I got mine from amazon at about 2$.
  3. Some jumper wires - so that you can connect devices on your Arduino and your breadboard. I picked up a neat set of male-to-male, male-to-female and female-to-female at Amazon. Cost of the whole kit? About 2$.
  4. A Few LEDs (and a few resistors) - which is the very first thing we will control with our code. You can also grab some resistors at 150 for just 1$ and a few LEDs for 3$.
  5. An ultrasonic transmitter - we will not be using it in the first demo, but we will need this in the third post, so it may be a good idea to get everything you will need in one shot. I picked up mine at 2$.
  6. A Wi-Fi module - that will eventually let you get connected to the internet over your home Wi-Fi connection and let you control the Arduino over an internet connection. Price? About 3$. Again, not something we will use in the first post, but something that we will use pretty soon.
  7. A Relay - that will let us control real live current / devices using our Arduino - we’re not going to use this for the next couple of posts but at 2$ a piece it’s something you may also want to order along with everything else mentioned above.

In under 25$ you have all you need to work on some meaningful IOT experiments and try out a few things.

We’ll get started with Arduino itself in this post and make it control a basic on-board LED light before we do some more interesting things with it. I do realize this example is highly non-practical but it is really simple, gets you used to the Arduino IDE and gets you familiar with the environment. So, let’s get started by making a LED blink, but before that lets begin by knowing our Microcontroller.

You can read article after after to understand the Arduino, but to start messing around with it, all you need to know is that is has 2 power output pins (using which connected devices can draw power) - one is a 3.3V power output pin, the other  a 5V power output pin. Apart from the power pins it also has ground pins labelled “GND” and all circuits that you make will usually end / complete with the ground pin. Put simply, your wiring will start with the power pin and end in the ground pin, and you will control everything else that’s in between (i.e. everything that’s connected to your IO pins).

Depending on the device you are connecting to your Arduino you can decide the power output you want to use. Most devices will have specs which will tell you how much power they expect. Exercise some common sense when you pick the power pin - for example, don’t connect your jumper wire to a 5V pin when the device you are connecting expects 3.3V - if you do there is a high chance you will cook your device.

Apart from the two power pins there are also some digital pins where you write a high or a low. Think of writing a “high” as turning a switch on and think of writing a “low” signal as turning the switch off. Out of all these pins, pin 13 is special because it has an in-built LED (light) attached to it that you can control with your code.

To write code we’re going to get the Arduino studio, which you can download from here and install using a simple installer. Once done, you connect your Arduino to the USB port of your laptop (which is one of the sources from which Arduino gets it’s power). Of course Arduino itself, can also work without a machine and you can hook it up with a battery or direct power, but for now since we will be uploading our code from our machine to the chip, it makes sense to have it connected with our laptop using the USB port.

Once connected go to your Arduino studio and pick the right port your Arduino is connected to. Usually the IDE automatically detects this but if it doesn’t you can try different ports and try to upload your code on each one till it succeeds. All code that typically runs on the microcontroller is referred to as a sketch and each sketch has a loop, which keeps on running as soon as the sketch is uploaded and the microcontroller is powered on.

An empty sketch looks like this.

Setup function is where you write code that runs only once. Anything you write in in “loop” runs in an infinite loop while the microcontroller is powered and on.

Now it’s time to connect the dots and assemble everything we’ve read thus far. Remember when we were talking about writing highs (which is same as turning the pin on) and lows(which is same as turning the pin off)? We know pin 13 has an in-built LED (light) and if we can write a high to pin 13, it should turn the switch on and the LED should glow. If we then write a low to the same pin the LED should shut off. If we do that in a loop function and wait 5 seconds between the on and the off, we should have an LED that keeps on blinking every five seconds the moment you power on the microcontroller. Simple enough? That’s exactly what we are doing in the code below:

int InBuiltLedPin = 13;

void setup() {
  // Let's set Pin 13 as Output Pin
  // Which means we will write high's and low's to it.
  pinMode(InBuiltLedPin, OUTPUT);

void loop() {
  // Turn on the Pin (and LED on board)
  digitalWrite(InBuiltLedPin, HIGH);
  // Wait for 5 Seconds
  delay (5000);
  // Turn off the Pin (and LED on board)
  digitalWrite(InBuiltLedPin, LOW);
  // Wait for another 5 seconds.
  delay (5000);

Verify your sketch (which is the same as compiling your code):

And once verified, upload your sketch on your Microcontroller:

And if all has gone fine you should see your Microcontroller LED blink on in five seconds (notice the Red LED next to pin 13 light up in the below picture):

And off in another five seconds:

Of course, this will continue in a loop till you switch off the microcontroller by pulling the USB cable off, or till you upload a new sketch.

And with that, you have just controlled an onboard LED with your code. In the next post, we will attach an external LED to the Arduino using a breadboard and try and change the same code slightly to make that LED blink. If you’ve never worked on electronics before the next post will introduce you to a lot of basic concepts like breadboards and resistors. And from there we’ll be ready to build some real life projects. So stay tuned for the next post.

posted on Saturday, October 8, 2016 6:33:14 PM UTC by Rajiv Popat  #    Comments [0]
Posted on: Sunday, July 17, 2016 by Rajiv Popat

Contagious (Book 7 of 52).

I’m a nerd and I’ve never read anything about marketing other than books from Seth Godin. When I came across Contagious at my office library I was a little skeptical because it sounded like one of those books on social media which tries to teach you how you can spread your business or product. Contagious however, was both pleasantly surprising and analytical.

The book starts with logical and then goes into the illogical aspects beyond your control which decide how and why your products spread. For example the book describes how the sales of Mars candy shot up in mid-1997:

Back in mid-1997, the candy company Mars noticed an unexpected uptick in sales of its Mars bar. The company was surprised because it hadn’t changed its marketing in any way. It wasn’t spending additional money on advertising, it hadn’t changed its pricing, and it hadn’t run any special promotions. Yet sales had gone up. What had happened?

NASA had happened. Specifically, NASA’s Pathfinder mission.

The mission was designed to collect samples of atmosphere, climate, and soil from a nearby planet. The undertaking took years of preparation and millions of dollars in funding. When the lander finally touched down on the alien landscape, the entire world was rapt, and all news outlets featured NASA’s triumph.
Pathfinder’s destination? Mars.

Mars bars are named after the company’s founder, Franklin Mars, not the planet. But the media attention the planet received acted as a trigger that reminded people of the candy and increased sales. Perhaps the makers of Sunny Delight should encourage NASA to explore the sun.

Or how every Friday, millions of individuals are ‘triggered’ to listen to Rebecca Black’s Friday:

In 2011, Rebecca Black accomplished a momentous achievement. The thirteen-year-old released what many music critics dubbed the worst song ever.
Born in 1997, Rebecca was just a kid when she released her first full-length song. But this was far from her first foray into music. She had auditioned for shows, had attended music summer camp, and had sung publicly for a number of years. After hearing from a classmate who had turned to outside help for her music career, Rebecca's parents paid four thousand dollars to ARK Music Factory, a Los Angeles label, to write a song for their daughter to sing.

The result was decidedly, well, awful. Entitled "Friday," the tune was a whiny, overproduced number about teenage life and the joys of the weekend.

All in all, the piece sounds more like a monologue of the random thoughts going through an especially vacant teenager's head than a real song.

Yet this song was one of the most viral videos of 2011. It was viewed more than 300 million times on YouTube, and many millions more listened to it over other channels.

Why? The song was terrible, but lots of songs are terrible. So what made this one a success?
Take a look at the number of daily searches for "Rebecca Black" on YouTube in March 2011, soon after the song was first released. See if you notice a pattern.

Searches for "Rebecca Black" on YouTube March 2011

Notice the spike once every week? Look closer and you'll see that the spike happens on the same day every week. There was one on March 18, seven days later on March 25, and seven days later, on April 1.
The particular day of the week? You guessed it. Friday—just like the name of Rebecca Black's song.
So while the song was equally bad every day of the week, each Friday it received a strong trigger that contributed to its success.

The book talks about dozens of other triggers and techniques you can use in your products to make them contagious and tries to weave it all into a simple framework the authors call the STEPPS framework:

  1. Social Currency: We share things that make us look good.
  2. Triggers: Top of mind, tip of tongue.
  3. Emotion: When we care, we share.
  4. Public: Built to show, built to grow.
  5. Practical Value: News you can use.
  6. Stories: Information travels under the guise of idle chatter.

While the book did leave me with a deep understanding of what is contagious and what is not, it also left me wondering if the contagiousness of products is easy to analyze in the hindsight and much more difficult to plan ahead of time? Would the authors be able to look at an idea or a product before it’s inception and say with certainty if it would be contagious?

Every piece of information the book provided was something every marketing person should know about and yet the book did not convince me that adding all six elements of STEPPS consciously in your product guarantees that your product would be contagious. The book is a good read and provides a nice technical framework to describe contagiousness and maybe even some really pointers to help spread your work and make it more contagious but it didn’t change my overall belief that all you can do as an individual is just keep showing up and hope that the magic of contagiousness touches your work every once in a while.

posted on Sunday, July 17, 2016 10:53:28 AM UTC by Rajiv Popat  #    Comments [0]
Posted on: Saturday, July 9, 2016 by Rajiv Popat

Born to Run (Book 6 of 52).

I’ve been running for sometime now. Last year I finally took the plunge and ran two half marathons back to back. But even today when it comes to running I’m a complete amateur who is lured by the pull of distance running.

The flow and the meditative aspect of long runs is something every person has to experience for themselves and if there is one book that can bring out the true sprit of distance running, it is Born to Run.

To be honest I came across the book (and the barefoot running movement) when I was searching for way to avoid minor shin splints that had been nagging more for a couple of days. I never expected a book on running to blow me away but born to run did more than just blow me away.

The story telling, the writing style and the research – it’s one of those books where it all comes together to create reality that is much more magical than fiction.

This was one of the few book that was just impossible to put down. From the Mexican Tarahumaras to the real world characters like Caballo Blanco, Scott Jurek and Jenn Shelton every character in the book touches you, teaches you and becomes a part of your life.

Chris Mcdougall is a true collector of fascinating characters, research and amazing real stories. All I can say is, if you haven’t read this book, you’ve seriously missed one of the best books you’re going to read - ever. And that’s true even if you have nothing to do with running. This book deserves a five star – and respect.

posted on Saturday, July 9, 2016 6:28:08 PM UTC by Rajiv Popat  #    Comments [0]
Posted on: Monday, June 6, 2016 by Rajiv Popat

Productivity Challenge Timer – How Focus Can Become A Game.

I’ve always been a fan of the Pomodoro Technique. It’s simple, it’s elegant and it works. You work for twenty five minutes, you focus on one thing and get it done. Then you allow yourself five minutes of distractions in a break and then you work for another twenty five minutes. You repeat this till your possibly can. There are physical twenty five minute timers you can buy for this.

But that’s just one aspect of Pomodoro. What if I told you that you could have a personalized Pomodoro instructor who would not just push you to work, but would demote you if you didn’t work hard enough. And he would even insult you and humiliate you with taunts if you were procrastinating. He would give you five minute breaks and once your breaks are over he would blow a loud whistle not just letting you, but your colleagues (who are hanging out with you) know that you now need to go back to work? Feels like an army trainer, doesn’t it?

I don’t know about you, but I like honest blatant truth. I mean if I can tell people to stop bitching and get back to work I don’t mind someone doing that to me. And I like tough instructors. No seriously; I do. One of the reasons I moved out of a gym and setup a gym at my home was because my gym instructor just wasn’t challenging me hard enough. And when it comes to work, I am also one of those people who don’t mind introspecting on questions like - Am I a Phony who hasn’t achieved much in life. The question (and the brutally honest answer I give myself) gets me down temporarily but pushes me forward in the long run.

So yeah, I love tough love - specially when I am dealing with myself.

And that is exactly why I love the Productivity Challenge Timer - which can be your personalized Pomodoro Instructor who has literally no feelings and is completely ruthless when it comes to getting you to work more.

The author of the application talks to you in first person and tells you how ruthless and unforgiving the application can be when it comes to getting you to work:

Work consistently and it promotes you and opens up new achievements for you which you can proudly flaunt. Cut some slack for yourself and the same app will not just humiliate you, but demote you with a loud sound so everyone around you at your workplace knows you were just demoted!

The app is humorous, it’s witty and the creepy part is, it’s addictive. And It makes you work! Folks around me now hear sounds and know when I am ready for a break. I am guessing they even know when I am promoted and when I am cutting slack or acting lazy or getting demoted. 

What’s even more amazing is that the app knows and understands the hard realities of distractions and meetings in the typical work environment. The other day, I worked for four hours completely meeting-and-distraction-free and the app not just gave me a promotion but told me in clear terms that ‘you worked for four hours today, which is rather rare in a typical office environment’ and it opened up an achievement for me.
I wasn’t able to work for four hours the next day because I had to interview four fresh candidates and the app wouldn’t listen to any of my excuses. It called me a ‘slacker’ and demoted me ruthlessly; leaving me with no options other than canceling some redundant meetings the next day and doing some more focused deep work.
There are very few apps that I literally use everyday of my life and Productivity Challenge Timer is one of them. I am not associated or affiliated with the app in any way; just a user who loves the app; and I would go so far as saying that if there is only one productivity application you are allowed to have on your phone, this should be that app! Especially if you like the idea of being tough to yourself and if you have a sense of humor.
Go download the free app and you’ll know exactly what I mean.
And… now if you will excuse me, I need to get back to work because Productivity Challenge Timer just started blowing the work whistle and I really don’t feel like getting demoted twice this week!

posted on Monday, June 6, 2016 6:45:26 AM UTC by Rajiv Popat  #    Comments [0]
Posted on: Sunday, April 24, 2016 by Rajiv Popat

Switch (Book 5 of 52).

I first read about the elephant Rider analogy in the famous book, The Brain That Changes Itself, which happens to be one of my all time favorite books in the field of Neuropsychology. The basic premise of the elephant-rider analogy is that your brain has two distinct systems:

The Elephant: which constitutes pretty much all of the primitive and 'automatic' parts of your brain starting from the brain stem to the limbic system and The Rider: which constitutes the more modern and 'thinking' parts of your brain like the Prefrontal cortex.

The basic premise being that the 'elephant' is primitive, huge and very powerful (obviously because it's machinery has been fine-tuned over millions of years of evolution). The rider is small (because these brain parts developed relatively recently in the timeline of evolution), but more controlled and has the capability of driving the elephant.

Even though the rider has a capacity of controlling the elephant, any time there is a major disagreement between the Rider and the Elephant, the elephant wins hands down and the rider stands no chance - Remember the last time you promised you will workout but then decided to watch TV instead of going to the gym when the evening arrived? There was a disagreement between the rider and the elephant and the elephant obviously won.

Switch - How to Change Things When Change Is Hard - takes this analogy of Rider and Elephant and handles the delicate topic of understanding this relationship between the Rider and the Elephant so that you can help your rider guide your elephant towards changes that you really want to bring about - not just in your life but in organizations and large groups of people.

Switch begins by understanding and appreciating the fact that the elephant is much more powerful than the Rider and in case of a disagreement between the two the Rider stands no chance.

The book also recognizes that both the Elephant and the Rider have their own problems. The Elephant is wild, hard to control and driven by emotions while the Rider is often a victim of over thinking, analysis paralysis and procrastination.

The book is all about, different ways of not just motivating the rider, but 'herding' the Elephant and making both work as a team. The 1% Milk campaign described in the book is a classic example:

Two health researchers, Steve Booth-Butterfield and Bill Reger, professors at West Virginia University, were contemplating ways to persuade people to eat a healthier diet. From past research, they knew that people were more likely to change when the new behavior expected of them was crystal clear, but unfortunately,"eating a healthier diet" was anything but.

Where to begin? Which foods should people stop (or start) eating? Should they change their eating behavior at breakfast, lunch, or dinner? At home or in restaurants? The number of ways to "eat healthier" is limitless, especially given the starting place of the average American diet. This is exactly the kind of situation in which the Rider will spin his wheels, analyzing and agonizing and never moving forward.

As the two researchers brainstormed, their thoughts kept coming back to milk. Most Americans drink milk, and we all know that milk is a great source of calcium. But milk is also the single largest source of saturated fat in the typical American's diet. In fact, calculations showed something remarkable:

If Americans switched from whole milk to skim or 1 % milk, the average diet would immediately attain the USDA recommended levels of saturated fat.

How do you get Americans to start drinking low-fat milk? You make sure it shows up in their refrigerators. And that isn't an entirely facetious answer. People will drink whatever is around the house-a family will plow through low-fat milk as fast as whole milk. So, in essence, the problem was even easier than anticipated:

You don't need to change drinking behavior. You need to change purchasing behavior. Suddenly the intervention became razor-sharp. What behavior do we want to change? We want consumers to buy skim or 1 % milk. When? When they're shopping for groceries. Where? Duh. What else needs to change? Nothing (for now).

Reger and Booth-Butterfield launched a campaign in two communities in West Virginia, running spots on the local media outlets (Tv; newspaper, radio) for two weeks. In contrast to the bland messages of most public-health campaigns, the 1 % milk campaign was punchy and specific. One ad trumpeted the fact that one glass of whole milk has the same amount of saturated fat as five strips of bacon!

At a press conference, the researchers showed local reporters a tube full of fat-the equivalent of the amount found in a half-gallon of whole milk. (Notice the Elephant appeals: They're going for an "Oh, gross!" reaction.)

Reger and Booth-Butterfield monitored milk sales data at all eight stores in the intervention area. Before the campaign, the market share of low-fat milk was 18 percent. After the campaign, it was 41 percent. Six months later, it held at 35 percent.

The book is full of really smart ways of directing the Rider and motivating / herding the Elephant. From preventing child deaths in Vietnam, to getting people to work out and stopping  their black berry addiction the book is literally full of real, pragmatic and practical steps you can benefit from starting today and how you can bring about change where change is hard just because the Rider and the Elephant are disagreeing or falling prey to their respective weaknesses.

And if you find yourself giving excuses like, "I don't have the power" or "the rules in this place are too crippling" - this book is a must read because it literally has tons of real life examples of people who brought about huge changes at organizational (and even national) levels without being given any special power or authority to bring about change.

For example, there is the story of Jon Stegner who lands up in an manufacturing company where he brings down the purchasing cost of gloves in his organization by a magnitude of a billion dollars, not by making a PowerPoint slide show or calling meetings and inviting people who just didn't care; but by piling up a heap of 424 different kinds of gloves with different price tags on the board room table to shock and motivate the elephants of  the directors and board members to bring about change.

And then there is the story of how Paul Butler, saves the  St. Lucia Parrot, in Caribbean island of St. Lucia without being given any power or authority to do so. The book is full of amazing stories from real walks of life about how people herd elephants and motivate riders to bring about change that eventually touches hundreds of lives. And it's not just the stories which makes this book gripping, but the scientific and methodical dissection of the stories from the aspects of phycology that makes this book equally educational.

There are very few books on human brain that you find 'inspiring' but this book is one of those rare books and one of those rare books that I would not hesitate to rate a 5 on 5.  If there only a couple of books you are going to read this year, this book should be in your must read list for this year.

posted on Sunday, April 24, 2016 10:22:43 AM UTC by Rajiv Popat  #    Comments [0]
Posted on: Thursday, March 24, 2016 by Rajiv Popat

How We Decide (Book 4 of 52).

Millions of years of evolution has fine tuned the human brain to use it's most primitive parts to take decisions in split seconds. The limbic brain along with your emotions are hugely powerful when it comes to your decision making capabilities and probably the only reason why you are alive today reading this blog. When the lion roars or when a huge mass of iron and steel on wheels is moving towards you at 60 miles an hour, your limbic brain is what causes you to run and saves you from becoming lion lunch or the subject of a car accident. The emotional system of our brain is much more powerful at making decisions than what most of us realize and give it credit for. Countless books have been written on this topic but if there is one book that brings a lot of the research on the topic together it is How We Decide by Jonah Lehrer.

John Describes the power of how important intuitions can be:

Riley had been on duty since midnight. At 5:01 in the morning, just as the Allied ships began shelling Ash Shuaybah, he noticed a radar blip off the Kuwaiti coast. A quick calculation of its trajectory had it heading straight for the convoy. Although Riley had been staring at similar-looking blips all night long, there was something about this radar trace that immediately made him suspicious. He couldn't explain why, but the blinking green dot on the screen filled him with fear; his pulse started to race and his hands became clammy. He continued to observe the incoming blip for another forty seconds as it slowly honed in on the USS Missouri, an American battleship. With each sweep of the radar, the blip grew closer.

It was approaching the American ship at more than 550 miles per hour. If Riley was going to shoot down the target—if he was going to act on his fear—then he needed to respond right away. If that blip was a missile and Riley didn't move immediately, it would be too late. Hundreds of sailors would die. The USS Missouri would be sunk. And Riley would have stood by and watched it happen.

But Riley had a problem. The radar blip was located in airspace that was frequently traveled by American A-6 fighter jets, which the U.S. Navy was using to deliver laser-guided bombs to support the Marine ground invasion. After completing their sorties, the planes flew down the Kuwait coast, turned east toward the convoy, and landed on their aircraft carriers. Over the last few weeks, Riley had watched dozens of A-6s fly a route nearly identical to the one being followed by this unidentified radar blip. The blip was also traveling at the same speed as the fighter jets and had a similar surface area. It looked exactly like an A-6 on the radar screen.

The target was moving fast. The time for deliberation was over. Riley issued the order to fire; two Sea Dart surface-to-air missiles were launched into the sky. Seconds passed. Riley nervously stared at the radar screen, watching his missiles race toward the object at speeds approaching Mach 1. The blinking green blips appeared to be drawn to the target, like iron filings to a magnet. Riley waited for the interception.

The explosion echoed over the ocean. All of the blips immediately disappeared from the radar screen. Whatever had been flying toward the USS Missouri helplessly fell into the sea, just seven hundred yards in front of the American battleship. A few moments later, the captain of the HMS Gloucester entered the radar room. "Whose bird is it?" he asked Riley, wanting to know who was responsible for destroying the still unidentified target. "It was ours, sir," Riley responded.

The captain asked Riley how he could be sure he'd fired at an Iraqi missile and not at an American fighter jet. Riley said he just knew.

John in his book goes on to describe how an excruciating investigation later goes on to conclude that Riley had indeed taken the correct decision and how Gary Klein a cognitive psychologist, later dissects what was going on in Riley's head when he took the call of shooting down the missile:

Klein was intrigued. He had spent the last few decades studying decision-making in high-pressure situations, and he knew that intuition could often be astonishingly insightful, even if the origin of those insights was obscure. He was determined to find the source of Riley's fear, to figure out why this particular blip had felt so scary. So he went back to the radar tapes.

He soon realized that Riley had gotten used to seeing a very consistent blip pattern when the A-6s returned from their bombing sorties. Because Riley's naval radar could pick up signals only over water—after a signal went "wet feet" he was accustomed to seeing the fighter jets right as they flew off the Kuwaiti coast. The planes typically became visible after a single radar sweep.

Klein analyzed the radar tapes from the predawn missile attack. He replayed those fateful forty seconds over and over again, searching for any differences between Riley's experience of the A-6s returning from their sorties and his experience of the Silkworm blip.

That's when Klein suddenly saw the discrepancy. It was subtle, but crystal clear. He could finally explain Riley's intuitive insight. The secret was the timing. Unlike the A-6, the Silkworm didn't appear off the coast right away. Because it traveled at such a low altitude, nearly two thousand feet below an A-6's, the signal of the missile was initially masked by ground interference. As a result, it wasn't visible until the third radar sweep, which was eight seconds after an A-6 would have appeared. Riley was unconsciously evaluating the altitude of the blip, even if he didn't know he was doing it.

This is why Riley got the chills when he stared at the Iraqi missile on his radar screen. There was something strange about this radar blip. It didn't feel like an A-6. Although Riley couldn't explain why he felt so scared, he knew that something scary was happening. This blip needed to be shot down.

The book is a fascinating read not just because it showcases how powerful our emotions can be in taking decisions, it also showcases when our emotions can lead us astray and provides real pragmatic advice on how to balance the emotional with the thinking parts of our brains to come up with better decision making capabilities.

The book itself is one of the better books on the human brains that I've read and I personally loved the book.  However, what was disheartening was learning that the book has been withdrawn from the market by publishers after the discovery of the fact that Lehrer had fabricated quotes used in his books. I would have personally quoted this book left right and center in my discussions with people, had it not been for the nagging doubt I have about the authenticity of every minute detail the book goes into. The author has been found guilty of fabricating facts and plagiarism but that still doesn't take away the fact that the book is a nice read and provides valuable insights that I never had before. I give this book a 4 on 5 and would definitely recommend this book to anyone who is interested in a deeper insights on what our brain is doing when it's indulging in the act of taking decisions.

posted on Thursday, March 24, 2016 8:16:52 AM UTC by Rajiv Popat  #    Comments [0]