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.

THERE’S A PASSION INSIDE YOU – A UNIQUE TALENT THAT GIVES YOU MEANING – DISCOVER AND LIVE IT. SAYONARA!

References –

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

https://www.gomadthinking.com/

http://qaspire.com/

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.

References-

https://dawidnaude.com/a-stoic-pyramid-c4c135896506

https://wallhere.com/en/wallpaper/1371395

 

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”.

chat-bots

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.

revolutionizing-procurement-with-artificial-intelligence-and-machine-learning-5-638

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.

F8111284-01.jpg

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" : "https://yourdomain.com"
}

Run apidoc

apidoc

You can find your documentation here.


/doc/index.html

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);
            }
        }
        list.push(img);
        img.src = array[i];
    }
}

The rise of ECMAScript – Goodbye 2015

What is ECMAScript?

toptal-blog-image-1435169544237-7137138c9b6badce17ca1e6094598255

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

babel

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(https://babeljs.io/) as it is actively supporting ES7 (ECMAScript 2016). For example Babel compiles following code:

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

to

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

which will run in any JavaScript environment.

 

Some more examples are Opal(http://opalrb.org/) for Ruby, Pyjamas(http://pyjs.org/) for Python, Perlito(https://github.com/fglock/Perlito) for Perl, j2js(https://github.com/decatur/j2js-compiler) for Java, Blade(https://github.com/vannatech/blade) for C# and so on.

Gulp and Grunt: Automate your workflows

gulp-grunt

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

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.

</pre>
$ cordova create hello2016 com.example.hello2016 Hello2016
<pre>

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 Gaana.com 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

    length-matters-2
    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.
    online-video-marketing

  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.
    going-viral007

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 = "https://www.youtube.com/iframe_api";
    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;(){
    if(window.pageYOffset&amp;amp;amp;gt;200){
    player.playVideo();
    }
    else if(window.pageYOffset&amp;amp;amp;lt;200){
    player.pauseVideo();
    }
    //console.log(window.screenY);
    }
  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>
    </div>
    
    
    

    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
http://wistia.com/
http://emarketingblog.nl
http://crispvideo.com

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,
    	"ignored_packages":
    	[
    	], 
    	"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.

loading-library-sublime

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
      Template.body.helpers({
        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:"http://www.seascapestudio.net/reference/fishes/centropyge_argi.jpg", createdAt: new Date() });
  6. check-db-for-fishes
    mongo-insert-singleton

  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:"http://www.seascapestudio.net/reference/fishes/centropyge_argi.jpg", createdAt: new Date() });
db.fishes.insert({ text: "blue dot grouper",imageurl:"http://www.richard-seaman.com/Underwater/Egypt/Highlights/PeacockGrouper.jpg", createdAt: new Date() });
db.fishes.insert({ text: "blue line grouper",imageurl:"http://www.aquariumdomain.com/images/fish_marine/grouper_blueline2.jpg", createdAt: new Date() });
db.fishes.insert({ text: "teira batfish",imageurl:"http://www.aquariumdomain.com/images/fish_marine/tieraBatfish8.jpg", createdAt: new Date() });
db.fishes.insert({ text: "convict blenny",imageurl:"http://www.roslyndakin.com/wp-content/uploads/2011/01/convictadult.jpg", 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:"http://bongotimes.com/wp-content/uploads/2014/11/beautiful-fish.png", createdAt: new Date() });

From MongoDB console run

db.fishes.find()

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
    

    meteor-remove-unsecure

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

    accounts-addition
    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:"http://bongotimes.com/wp-content/uploads/2014/11/beautiful-fish.png", createdAt: new Date() });
    

    meteor-not-authenticated

    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.

References-
https://github.com/Slava/tern-meteor-sublime

Images credits-
http://bongotimes.com/

Advanced Javascript: Introduction To Server Side Javascript Using Meteor

Server Side Javascript has come long way, and after launch of Node.js in July 2011 gained lot of popularity as idea of using same language on client and server bought in code and software architecture uniformity in software applications. Even though Brendan Neich‘s Netscape already had vision to use same programming language on client and server but at that time people were using Pentium I/II processors which were not powerful enough to support Javascript Interpreters. In case you don’t know Brendan Neich he’s creator of Javascript and co-founder of Mozilla. In present generation of more than 2 billion smartphones you can get Phone with 1.2 GHz processor for less than $40. Seeing boom in processing speed of devices software developers started integrating Javascript interpreters like SpiderMonkey & Rhino in their applications. Some started using Jaxter server that embeds entire Mozilla Firefox Browser Engine in web server giving access to Ajax and Javascript within application.

Now when we have brief history of Javascript let me explain how to setup Meteor and create a simple server side Javascript application.

Go to this link and install Meteor.

Once you are done with setup go to command like and create a directory named bluefish if you would like to follow remaining series of tutorial.

Nikhils-MacBook-Pro:bluefish nikhil$ meteor create bluefish
Created a new Meteor app in 'bluefish'.
Nikhils-MacBook-Pro:bluefish nikhil$ cd bluefish/
Nikhils-MacBook-Pro:bluefish nikhil$ meteor
Started proxy.
Started MongoDB.
Started your app.  
App running at: http://localhost:3000/

Screen Shot 2015-10-24 at 4.10.07 pm Screen Shot 2015-10-24 at 4.16.08 pm

Now navigate to http://localhost:3000/ and if everything if fine you will see following webpage-
Screen Shot 2015-10-24 at 5.07.16 pm

Now you can use your favourite code editor to change HTML and CSS and see if changes are getting reflected in your application without refreshing browser. If you can see updated HTML in your browser, congrats you deployed your first Javacsript Server Side Application. It’s called hot code push.

Now lets dig in a little and make our first bluefish list.

Edit your HTML and change it to

<head>
  <title>bluefish!</title>
</head>
 
<body>
  <div class="container">
    <header>
      <h1>bluefish!</h1>
    </header>
 
    <ul>
      {{#each fishes}}
        {{> fish}}
      {{/each}}
    </ul>
  </div>
</body>
 
<template name="fish">
  <li><img src={{imageurl}} height="80" width="100"/>{{text}}</li>

</template>

Change your Javascript to

if (Meteor.isClient) {
  // This code only runs on the client
  Template.body.helpers({
    fishes: [
      { text: "pygmy angelfish",imageurl:"http://www.seascapestudio.net/reference/fishes/centropyge_argi.jpg" },
      { text: "blue dot grouper",imageurl:"http://www.richard-seaman.com/Underwater/Egypt/Highlights/PeacockGrouper.jpg" },
      { text: "blue line grouper",imageurl:"http://www.aquariumdomain.com/images/fish_marine/grouper_blueline2.jpg" },
      {text:  "teira batfish",imageurl:"http://www.aquariumdomain.com/images/fish_marine/tieraBatfish8.jpg"},
      {text:  "convict blenny",imageurl:"http://www.roslyndakin.com/wp-content/uploads/2011/01/convictadult.jpg"}
    ]
  });
}

You can write your custom styling in CSS file.

Screen Shot 2015-10-24 at 5.02.14 pm

For further information, visit https://www.meteor.com/tutorials/ or wait for next chapter of tutorial. Happy coding!

Image credits-

http://www.seascapestudio.net/
http://www.richard-seaman.com/
http://www.aquariumdomain.com/
http://www.aquariumdomain.com/
http://www.roslyndakin.com/

References-
https://developer.mozilla.org/ja/docs/Web/JavaScript/Server-Side_JavaScript
https://www.meteor.com/