Count Your Blessings, Good Times Will Follow!

COVID has hit us hard and it’s sad truth that we lost almost 3 million lives are living and passing through this pandemic for more than a year now. Kind of we used to see in movies and television series like Resident Evil and 12 Monkeys. We are experiencing it live. From work from home, long queues outside shopping malls, home quarantines, not being able to hug our closed ones staying in same home & poor migrants standing on borders to reach their own homes. Job loss, loss of closed family members, delayed salaries, no vacations, lockdowns, travel restrictions and lot more.

We all are facing it & together. I faced it, depression- to the core that I felt I am surrounded with black cloudy thoughts along with thunderstorms. All playing with my head and heart. Moving on and admitting the situation was difficult. Soon after I realised that I am getting into depression due to personal losses and trail of traumatic events I went through during pandemic, I realised that I need to get out of this else I would dig my own emotional grave. I know there are people who would critic or even think what the hell am talking? But it doesn’t matter. For emotional people it will make more sense to dig this article deeply as it might help you to change your outlook and generate more optimistic approach towards life.

First thing I had to understand was “ACCEPTANCE“. This might sound easy but it isn’t. Wasn’t easy was me at least. I had to give my all in to accept the truth about myself. Again, just myself. Accepting the fact that there will be sunrise after dark and dark after sunrise was difficult for me to accept. I was living in my own dilemma willing everything to go my way and the way I was living life was to create artificial sunrise even when it was dark. The “Law Of Attraction” was working. Fight or Flight. Soon I met someone who got me to dig deep in this word called “ACCEPTANCE“. I am going to emphasise a lot on this word throughout the article as it was building block for rest of my thought process. I could’t go any further till I understood this word deeply and admitted that my grandiose thinking was not helping me. Nothing was under my control, I realised. “Law Of Attraction” stopped working and I was sitting in my room, all alone with no one around me. Selfishness-self-centeredness! This was root of my trouble. I was driven by thousands form of fear, self-delusion, self seeking and self-pity. My self-will placed me in a position to be hurt.

Later and hardly, I had to accept that things will happen their own way and I have to act spectator sometimes. I also came across a poster that grilled my thought process even further.

Don’t Avoid Storm, Just Let It Pass. Just Sail.

Law of Attraction” started working as I stopped expecting and became less judgemental. Fight of Flight stopped. Accepting situations and sailing through became easier. Even in worst situations I started counting more of my blessings. I had new Employer in form of Acceptance and I started believing that there is some power who is planning things for me that I was not able to plan for myself. Established on such thought process, I became less worried and less interested in my own self will. I had little plans for myself. I started enjoying beach from shore and black clouds from earth avoiding prediction of when it’s going to rain.

As I felt new power flow in I started enjoying peace of mind and was able to face life with more optimistic outlook, one day at a time. I started to become more conscious and started losing fear of today, worry of tomorrow or hereafter. It was like emotional rebirth, having new perspective towards life which was not driven by my self will. I had to quit playing God and this was keystone of new triumph through which I had feel of freedom from my own entangled thought process which was self-will run riot. At times you could just sit under lemon tree waiting for nothing to happen and you will feel life will happen when you are busy making other plans. A song for those who tool this article too seriously. ūüôā

IKIGAI- Japanese way to find your Raison d’√™tre with 10 rules

The clock striked twenty one and a man knocked my door to serve milk. With extreme professionalism he entered my room and kept glass on my table without making any noise and was about to leave.

I stopped and asked him, “Bhaiya(Brother in english), where are you from?”.

He responded, “From the village, Sir”.

Further I asked, “From how much time are you here?”.

Calmly he responded, “3 years Sir”.

I enquired, “How much do you earn?”.

This time he responded with a big smile on his face, “Enough to take care of my family Sir” and left the room.

I started noticing him on a daily basis- everyday he would softly knock at my door and with utmost professionalism put milk on the table and leave my room with a smile. One day I stopped him and asked, “How come you are so happy every time?”. He responded, “I love my work, Sir. I never get tired cause of it and I relish the responsibility to take care of my family and customers. It gives me a purpose to live”.

It got me into a state of retrospection, and I asked myself – “When did I feel the same for the last time?”. I called up few of my friends to just to check. I asked them, “How is work? How is life?”. Most of the answers were, “Going on. Problems. Family Issues. Relationship Issues.”. Not even single person responded that they were satisfied, happy or passionate.

I started talking to people about it to get into core of it. Recently, one of my expert advisor suggested me to read Ikigai: The Japanese Secret to a Long and Happy Life– Japanese way to find your Raison d’√™tre. Japan is known for its longevity. Average life expectancy in Japan is almost 75 which is highest in the world. It is said its due to their passion towards work and cause they keep themselves busy in what they love and are passionate about their life expectancy is best in the world.

Oops, for readers who didn’t already google, Raison d’√™tre is a french word meaning “the most important reason or purpose for someone or something’s existence“. IKIGAI as science talks about your Raison d’√™tre (purpose in life) and how could it help to keep you busy and increase your longevity.

First lets try to understand meaning of IKIGAI with help of a diagram, later we will jump to 10 rules which will help us practice IKIGAI.

Lets pick up pen and paper and start answering following-

  1. What is your passion (What you love)?
  2. What is your mission (What the world needs) ?
  3. What is your vocation (What you are good at)?
  4. What is your profession (What you can get paid for)?

Take your time and jot down whatever comes to your mind before we proceed. I always thought writing was useless being from technical background but trust me once I started doing it it granted me lot of superpowers to express myself. So, if you are checking this blog just casually and are short on time come back later and finish this exercise.

Now lets analyse, where do you fit in above diagram? Ok, lets make it simple. If your profession and passion are same, you may feel satisfied but there could be feeling of uselessness.

Similarly, if you are a kind of person who is on a mission which is also your vocation, say you are are a gymnast are you are willing to participate in Olympics. Your life will be full of excitement & complacency but there will be sense of uncertainty.

‚ÄúYour ikigai is at the intersection of what you are good at and what you love doing,‚ÄĚ says Hector Garcia, the co-author of Ikigai: The Japanese Secret to a Long and Happy Life. Understanding of where you fit or are willing to fit is very important to practice 10 steps of IKGAI. As you can see in diagram, IKIGAI is blend of everything, you can’t cook good meal unless you have all the ingredients. Just having best quality burger buns are not suffice to make awesome burger.

I hope you got crux of IKIGAI and now understand why its important and how can it help to increase your life expectancy and keep you content while following your passion.

10 Rules of IKIGAI

Even though am not a philosopher to review but this image describes 10 rules of IKIGAI perfectly. It means if you do things of value in calm and composed manner surrounded by friends while keeping yourself physically and mentally fit with feelings of gratitude and no regrets of past, is when you will be able to follow your IKIGAI.


References –

Ikigai: The Japanese Secret to a Long and Happy Life (Book Review)

Orion Philosophy – ancient wisdom for modern times

Its 10:30 PM, am sitting in my room surrounded with magnificent garden and my eyes were stuck at angelic Buddhist fountain for long before I decided to write this blog on Philosophy.

Most of you being technical readers, I will quickly explain what philosophy is. Philosophy is a way of life. Its our decision making capability to manage our emotions and thoughts. Each one of us have our own philosophical controller that helps us in making important and non important decisions in life. For geeks, its an autonomy advisor that helps us take decisions linked to real world issues. A good philosophy towards life is very important for us to control our thoughts and emotions to live stress free life during modern times.


While trying to understand human philosophy and meaning of life I started talking to people who were studying them. Recently I met a friend who introduced me to a philosophy that slowly started changing my perception towards life and the way I was pursuing it. Its called “Orion Philosophy” which talks of Stoicism as its core value. Stoicism means ‘the endurance of pain or hardship without the display of feelings and without complaint‘. It was founded by¬†Zeno of Citium¬†in Athens in the early 3rd century BC, long before Jesus was born.

If you are thinking same as me, finding meaning of life is somewhat confusing and elusive. We struggle to find purpose of life and get ourselves entangled in our own emotions and thoughts leading to foggy behaviour and decision making. While exploring I came across various articles and blogs on Stoicism and its practical implementations in life. I will be putting references to all of of them at bottom.

One interesting cheat sheet that I came across was of David Stoic which depicts Stoic philosophy as a pyramid.

Top of pyramid says, there is good chance that it will go bad but you will be ok. This is most important step to make your more stoic. It means you should know the difference between things you can change and things you can’t. What is yours and under your control will come to you but what is not in your control, you must not dwell on it.

Live Simply. Try living a simple life while pursuing what you love doing as it will give you much more satisfaction than anything that’s materialistic.

What’s done is done. You cannot change what is already done, so worrying about it is only going to create more misery. Rather focus on good things in life and practice mindfulness by practicing healthy lifestyle. Whenever you feel your mind is stuck in things you cannot change deviate yourself. Get a hobby, exercise, go out for a walk, do YOGA and try other mind relaxing techniques.

Here’s powerful video of Epictetus who was one of the most prominent Stoic philosophers of the ancient world. Not putting too much of cognitive load on readers I will end this blog here and soon start writing Part 2 where we will discuss ‘Nihilism’. Happy Reading.



Human vs Artificial Intelligence – Quick Insight

Screen Shot 2017-12-27 at 1.31.33 AM

What makes your life easier than a technical secretary who¬†says, “What can I do for you Anonymous? I¬†can help you solve real-life problems, and I can also help you with things that I don’t¬†understand¬†by connecting you to a human”.


This is how a life of new-born bot starts. As a kid getting trained on real-world problems via Natural Language Processing- Artificial Intelligence Based Human Language Interpretation to invoke technical callbacks. Callbacks that invoke functions like triggering ON and OFF event for a switch in case of Smart Homes like Home,  wake me up at 7 AM tomorrow in case of smartphones virtual assistants like Siri & Google Assistant.


Artificial intelligence is in competition¬†with humans by automating human work and reducing the human workforce. There are a lot of discussions around fact that there is a segment of¬†humans who don’t like bots and technology, they just don’t want to lose their job to a bot.


But for¬†those who understand that we should rather try to automate things than doing everything by ourselves just to feel ownership, “We are not the owner of anything in our life. We cannot control mind and body”. ¬†People¬†were using landlines before they¬†started using mobile phones, and with time¬†they¬†started learning about¬†social media websites like Facebook, mobile messengers like WhatsApp¬†and traveling with Uber.

If you are here and trying to understand IoT- any device that is connected to internet/ network and can be controlled over same using apps on mobile phones, smart watches or web apps is an IoT device. An IoT device can be a light, air conditioner, speakers, music system in your car, energy monitors etc. If you are techie you can buy one of RaspberryPi starter kit and unleash your creativity.

Merry Christmas!

Creating API documentation from source code comments in JavaScript, C#, PHP & JAVA

From past 5 years I have been working with lot of technical teams struggling to version APIs and create API documentation as per spec change. After boom of version control tools like Github & SVN teams are able to track source code but updating API specs for every minor change is still something that developers forget or don’t really care to update on time. It doesn’t matter much if nobody else is consuming their APIs but if APIs are exposed as REST-¬†developer/app should know¬†at same time that something was changed in API.

Teams are still able to track major API version releases but minor spec change in APIs are untracked most of the time, sometimes cause of communication gap and sometimes cause of improper documentation, leading to frustration within teams and products. As developers, how do we version our APIs without giving this responsibility to one more person who has to coordinate with each and every developer of team trying to figure out what was updated and manually updating documentation at end of the day?

Recently, I came across a tool that made my life as a product developer plain sailing. Now the developer who is working on server side API needs to add comments in his code in proper format and anyone from team will be able to generate API document out of it. Whenever server team works on any functionality they update comments in their own code giving it a minor release number if required and team will be able to generate documentation if they have access to latest updated server code without knowing server code language on my local. Take below example for instance

 * @api {POST} /route/api/ Login
 * @apiName Login
 * @apiGroup Authentication

 * @apiParam {Username} Username
 * @apiParam {Password} Password
 * @apiParamExample {json} Request-Example:
* "Username": "test",
* "Password": "Test123",
 * @apiSuccessExample Success-Response:
 * "Code": 1,
 * "Message": "Signed in Successfully",
 * @apiError User Id/Password Is Incorrect.
 * @apiErrorExample Error-Response:
 * "Code": 1,
 * "Message": "User Id password is incorrect",

 * @api {POST} /route/api/ Signup
 * @apiName Signup
 * @apiGroup Authentication

 * @apiParam {Username} Username
 * @apiParam {Password} Password
 * @apiParam {Email} Email
 * @apiParam {FirstName} FirstName
 * @apiParam {LastName} LastName
 * @apiParamExample {json} Request-Example:
* "Username": "test",
* "Password": "Password",
* "Email": "Email",
* "FirstName": "FirstName",
* "LastName": "test",
 * @apiSuccessExample Success-Response:
 * "Code": 1,
 * "Message": "Signed up Successfully",
 * @apiError User Id/Password Is Incorrect.
 * @apiErrorExample Error-Response:
 * "Code": 1,
 * "Message": "Please check details again",

The above code in your own JavaScript/C#/PHP will generate an API documentation for you with an awesome left menu and standard parallax style API documentation.

Install apidoc using npm

npm install apidoc -g

Create apidoctemplate directory in root of your project

apidoc -i js/ -o apidoc/ -t mytemplate/

Create apidoc.json

vi apidoc.json

Configure your apidoc.json

"name": "My REST API documentation",
"version": "0.1.0",
"description": "My REST API documentation",
"title": "Detailed REST API documentation",
"url" : ""

Run apidoc


You can find your documentation here.


Now each time your server-side developer friend updates any spec ask him to edit the comment in code and your updated REST API documentation is ready.

Saturday, April…

Saturday, April 14th, 2012

Its 2:24am in the morning and I thought to share some experience about my feelings at a job with all you folks. ‘CONTENT’, a word used in a very ‘inspiring’ way, by someone I adore, to boost me up. It¬†means¬†you are happy, and while you may not think things are perfect, you can be happy despite that. Am sitting in my cubicle in my workplace.

I live with¬†room partners. One of them is DBA and other is Software Tester working in the same¬†company, which¬†I work for. One of them is television(Sas Bahu) fan, and the other is afraid of future at age of 21. They are my good friends. Most of the Indian software ‘PROFESSIONALS’ are like this.

I have a manager who thinks, that employees are known by hard-work, not by ‘SMART-WORK’. My IT architect adores smart work, but he’s always busy. I can understand his hectic schedule. My room partner works for the same team, which I work for.

I am kind of person who loves his work. If I have something to do, I don’t care who I work for, my aim aims to love it, and make the best out of it. I love having ‘FUN’. Let me tell you not a person with very high IQ.

Recently, I met¬†few guys from who started up a new company in Bangalore. They had a small workplace, with around 20 people(guess), compared to my medium sized office with around 150 employees and, my office is air-cooled. People, out there were inspiring, full of ideas, living their own lives. There was a feeling of ‘FREEDOM’ in them. India got free on August 15, 1947. My office has its own dress code, timing restrictions, project deadlines, access cards, rules, and regulations.

I don’t know if you noticed the words I have highlighted. ‘CONTENT’, ¬†‘PROFESSIONALS’,¬†‘SMART-WORK’,¬†‘FUN’,¬†‘FREEDOM’. These are the words, which can describe, any software engineers or any other professional.

Confused? Don’t scratch your brains too much, listen to this.

High-Hopes(Pink Floyd)

JS code snippets- Preloading images using JavaScript

There are cases when you want your JavaScript to save all the images in browser cache so as to avoid loading them required. Let’s say you have a select box where you select something and the corresponding image changes somehow. You can use the following code snippet to store and cache all images returned from an array in your browser cache

function preloadImages(array) {
    if (!preloadImages.list) {
        preloadImages.list = [];
    var list = preloadImages.list;
    for (var i = 0; i < array.length; i++) {
        var img = new Image();
        img.onload = function() {
            var index = list.indexOf(this);
            if (index !== -1) {
                // remove image from the array once it's loaded
                // for memory consumption reasons
                list.splice(index, 1);
        img.src = array[i];

The rise of ECMAScript – Goodbye 2015

What is ECMAScript?


As per Wiki-  ECMAScript(European Computer Manufacturers Association) is a trademarked [1] scripting language specification standardized by Ecma International in ECMA-262 and ISO/IEC 16262. We use various implementations of ECMAScript for client side scripting on web. Examples are JavaScript, ActionScript and Jscript.

ECMAScript was developed by Brendan Eich- Father of JavaScript. It was named Mocha, then Livescript and finally JavaScript.

ECMAScript7: The rise of compilers


After ES6 (2015), there was huge rise in number of developers switching from traditional way of writing JavaScript to start using compiled code generators. Compiled code generators compiles code written in other languages to JavaScript. Our favourite JS code compiler is Babel( as it is actively supporting ES7 (ECMAScript 2016). For example Babel compiles following code:

const input = [1, 2, 3];
console.log( => item + 1)); // [2, 3, 4]


var input = [1, 2, 3];
console.log( (item) {
return item + 1;
})); // [2, 3, 4]

which will run in any JavaScript environment.


Some more examples are Opal( for Ruby, Pyjamas( for Python, Perlito( for Perl, j2js( for Java, Blade( for C# and so on.

Gulp and Grunt: Automate your workflows


Measuring programming progress by lines of code is like measuring aircraft building progress by weight. ‚Äď Bill Gates

With active usage of tools like Gulp and Grunt companies and developers started automating workflows for JavaScript applications. These tools helped developers in doing lot of automated tasks like library upgrade, automated testing, folder structure creation and so on. If you didn’t use Gulp and Grunt in your projects till now and make a New Year resolution to automate your build process and automate JavaScript tasks for an easier life.

The incredible Node.JS


Node.js foundation grew to more than 3 million users. Companies like Intel, IBM and Joyent used Node.js to create software architectures, real-time location tracking services and IoT. With npm lives of developers became lot easier as they could do a lot of heavy architecture creation using CLI. Also I heard companies switching from traditional Java/PHP technology stack to next gen Node.js for their active products.

How rise of ECMAScript revolutionized cross-platform apps

This year we saw a lot of people moving from native to cross-platform and vice versa. Keeping same codebase across all platforms helped companies and developers to launch their products in really less time when compared to writing code in different languages for each platform. With tools like npm creating a Cordova application became one liner.

$ cordova create hello2016 com.example.hello2016 Hello2016

We can’t wait to see what ECMAScript7 will bring in for developers working on IoT and next generation apps in 2016. Wishing all readers Techie-Happy New Year.

Video Advertising: Tips, how to play and pause YouTube videos on scroll and story behind Adele’s Hello

A lot of start-up advertisers and enthusiasts ask me about importance of video advertising. Recently, I met one friend who wanted to embed video ads in his app and website, the kind of ads you see on or auto play videos on Facebook which auto start and pause when you scroll.

Businesses also ask what kind of videos will work for their business. Here are few tips.

  1. Shorter is better ‚Äď watch trailer before you go for movie

    Video length significantly determines how many people are going to watch your video. Just like you prefer to watch movie’s trailer before planning to spend 2 hours to watch entire movie, people prefer to watch 30 seconds trailer about your business, if they like the trailer they will definitely watch 30 mins video about your business and maybe turn to your loyal customers.

  2. Quality of video ‚Äď short creative motivating story

    After length its quality of video that you are putting on your website or app. A short creative story that motivates customers to go for your business rather than other players in market is the key.

  3. Viral ‚Äď market your video using various channels

    This is one term that is viral over internet. I remember when people used to share videos over email, when YouTube was not there. ‚ÄúThe Spirit of Christmas‚ÄĚ was distributed over email and it led to creation of adult comedy animation series ‚ÄúSouth Park‚ÄĚ. Now you have got lot of channels like YouTube, Facebook, Twitter and other social media platforms. Utilize them well.

I feel, video advertising is in huge demand right now but there is no inventory. There are a lot of online tools that you can use to create good videos for your business. I am pasting small list here.

Now let’s go core technical and play and pause a YouTube video on scroll.

  1. In your script tag load the iframe Player API code asynchronously
    var tag = document.createElement('script');
    tag.src = "";
    var &lt;span class="mceItemHidden" data-mce-bogus="1"&gt;&lt;span class="hiddenSpellError" pre="var " data-mce-bogus="1"&gt;firstScriptTag&lt;/span&gt;&lt;/span&gt; = document.getElementsByTagName('script')[0];

    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  2. after the API code downloads, create a YouTube Player
    var player;
    function &lt;span class="mceItemHidden" data-mce-bogus="1"&gt;&lt;span class="hiddenSpellError" pre="function " data-mce-bogus="1"&gt;onYouTubeIframeAPIReady&lt;/span&gt;&lt;/span&gt;() {
    player = new YT.Player('player', {
    height: '390',
    width: '640',
    &lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;videoId&lt;/span&gt;: '&lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;769SeL9QiFw&lt;/span&gt;',
    events: {
    '&lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;onReady&lt;/span&gt;': &lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;onPlayerReady&lt;/span&gt;,
    '&lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;onStateChange&lt;/span&gt;': &lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;onPlayerStateChange&lt;/span&gt;
  3. On player ready set window.onscroll to check for video position on scroll
    function &lt;span class="mceItemHidden" data-mce-bogus="1"&gt;&lt;span class="hiddenSpellError" pre="function " data-mce-bogus="1"&gt;onPlayerReady&lt;/span&gt;&lt;/span&gt;(event) {
    window.onscroll = function() {&lt;span class="hiddenSpellError" pre="function " data-mce-bogus="1"&gt;checkIfToPlayVideo&lt;/span&gt;()};
  4. Check scroll position and play pause video
    function &lt;span class="mceItemHidden" data-mce-bogus="1"&gt;&lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;checkIfToPlayVideo&lt;/span&gt;&lt;/span&gt;(){
    else if(window.pageYOffset&amp;amp;amp;lt;200){
  5. Add div that will get replaced by YouTube iframe
    &amp;lt;div style="height:&lt;span class="mceItemHidden" data-mce-bogus="1"&gt;&lt;span class="hiddenSpellError" pre="" data-mce-bogus="1"&gt;800px</span></span>;position:relative;"&gt;&amp;<span class="hiddenSpellError" pre="" data-mce-bogus="1">nbsp</span>;
    <h1>Scroll down to play Video</h1>
    <div id="player"></div>
    <div style="height:800px;position:relative;">&nbsp;
    <h1>Scroll to top to pause Video</h1>

    Great, you created Facebook like video experience. You can manipulate viewport based on your requirements. You can also check live demo here.

    Story behind Adele‚Äôs latest hit ‚ÄėHello‚Äô

    There were rumours that Adele wrote this song after her breakup. As per her official interview if she would have written ‚ÄėHello‚Äô for her lost love it would be full of pain. But this video was not intended to be on ‚Äėdark side‚Äô. The other side is not dark. There was a girl in her 20‚Äôs going through bad phase and people called her immature, emotionally stable on social media and compared her to Taylor Swift and there is a mature lady writing from a place out of her comfort zone and singing ‚ÄėHello from the other side‚Äô.

    Happy Advertising and Coding! Enjoy ‘Hello’ in demo.

Image copyrights

Advanced JavaScript: Environment Setup, DB integration and Securing Client in MeteorJS

This tutorial is in continuation with previous tutorial. If you are new here, read first chapter of this series Advanced JavaScript: Introduction To Server Side JavaScript Using Meteor before reading this tutorial.

I will be skipping traditional TO DO app tutorial here, as you can find it anywhere on web. Rather, I will try to explain few scenarios that developers come across while developing apps using JavaScript frameworks in real-time.

In this tutorial we will be covering

  • Setting up development environment for Meteor?
  • How to integrate your Meteor application with Mongo DB?
  • How to secure your Meteor application?

Setting up development environment for Meteor
Most popular IDEs like Sublime, Webstorm and on-cloud IDE- Cloud 9 integrates seamlessly with Meteor. I am a fan of Sublime so I will explain how to set up autocomplete engine into Sublime Text 3. You can visit Meteor website and setup your own IDE.
Open Sublime Text-

  1. From menu bar select preferences-> Settings -Users
  2. If you have not made any changes from time you installed Sublime replace contents of file with following code-
  3. {
    	"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
    	"font_size": 12,
    	"auto_complete_triggers": [ { "characters": "<", "selector": "text.html" }, { "characters": ".", "selector": "source.js" } ]
  4. Now press Cmd/Ctrl+Shift+P and type Install. You will see ‘Package Control: Install Package’ in menu. Select it and press Enter. Now search for TernJS and click on it. Package will install automatically. Restart Sublime and you will see your Sublime just got smarter and it can autocomplete Meteor code for you.


How to integrate your Meteor application with Mongo DB?
We already have Meteor code running on local server. Now let‚Äôs add DB support. Meteor comes bundled with MongoDB so you don’t need to include it again, still if you wish you can do custom setup but let‚Äôs not discuss it in this tutorial as pre bundle itself is self-sufficient to create end-end application.

  1. Lets create Fishes collection.
    Fishes = new Mongo.Collection("fishes");

    It creates a MongoDB collection called Fishes and creates a cache connected to server.

  2. Replace if (Meteor.isClient) with this code
    if (Meteor.isClient) {
      // This code only runs on the client
        fishes: function () {
          return Fishes.find({});
  3. From terminal type
    meteor mongo
  4. meteor-mongo-terminal

  5. Now write this insert query to add a new fish

    db.fishes.insert({ text: "pygmy angelfish",imageurl:"", createdAt: new Date() });
  6. check-db-for-fishes

  7. Now go to http://localhost:3000 and check if you are can see live fish coming from live data. If yes, you just added DB connectivity to your meteor application.

Now add some more blue fishes to grow your list-

db.fishes.insert({ text: "pygmy angelfish",imageurl:"", createdAt: new Date() });
db.fishes.insert({ text: "blue dot grouper",imageurl:"", createdAt: new Date() });
db.fishes.insert({ text: "blue line grouper",imageurl:"", createdAt: new Date() });
db.fishes.insert({ text: "teira batfish",imageurl:"", createdAt: new Date() });
db.fishes.insert({ text: "convict blenny",imageurl:"", createdAt: new Date() });

How to secure your application?
One of main concern while using JavaScript for both server and client side code is security. Try running following code from console:

Fishes.insert({ text: "Fighter",imageurl:"", createdAt: new Date() });

From MongoDB console run


and you will see both client and server have a new beautiful red fighter fish. If you noticed, you were able to alter DB using Javascript without authenticating with server which is a security breach. This is beacause Meteor has insecure package selected by default.

  1. To remove insecure package navigate to your project folder in Command Line /Terminal and run-
  2. meteor remove insecure


  3. Now enable the accounts system and UI using following command from root directory of project-
  4. meteor add accounts-ui accounts-password

    I find package control really useful. They make your life lot easier by taking care of entire setup for useful technical modules, as in this example entire user management. Few years back implementing secured login module was estimated around 100 hours which came down to 1 minute with recent advancement in web technologies.

  5. Now add login buttons to your app. Paste following blaze template anywhere in code. I will paste it in header.
  6. {{> loginButtons}}
  7. Now signup for new account and run this command from console-
  8. if (! Meteor.userId()) {
          throw new Meteor.Error("not-authorized");
    Fishes.insert({ text: "Fighter",imageurl:"", createdAt: new Date() });


    You will notice you are not able to insert data any more. Meteor.user() will return user data to you.

We will discuss security, Blaze templates and routing in detail in next chapter of this tutorial. Till then Happy Coding!

Now you can follow this tutorial on GitHub.


Images credits-