Author Archives: Ajitesh Kumar

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Javascript – Jasmine Unit Tests for Promise Object

This article represents tips and code samples in relation with how to write unit tests for Promise object when using Jasmine framework. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: Sample Promise Object Unit Tests related with Promise Object Sample Promise Object Pay attention to some of the following in the code below: Auth module returns a Promise object that returns a User object when resolved or returns an error object in case of error. A JSON object is passed to resolve or reject method. Save the file …

Continue reading

Posted in Javascript, UI, Unit Testing. Tagged with , , .

Javascript – How to Define & Process a Promise Object

This article represents tips and code samples on How to define and process a Promise object. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: How to Define a Promise Object How to Process a Promise object How to Define a Promise Object Following demonstrates the Auth module with an API, login, that returns a Promise that will be resolved/fulfilled or rejected later with appropriate object representing domain object such as User or error object with status and error message as demostrated below. // Promise needs to be imported …

Continue reading

Posted in Javascript. Tagged with .

Javascript – Jasmine Unit Tests Explained with Code Samples

This article represents instructions and code samples on how to setup Jasmine along with unit tests code samples. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: Set up Jasmine Development Environment Set the Jasmine Config Property Create Javascript Files including Jasmine.json, JS Modules & Unit tests Setup Jasmine Development Environment I would suggest setting up a Docker image for Javascript environment consisting of key tools such as grunt, jscs, jshint, typescript, browserify, nodejs etc. Check my page on How to setup Javascript Dev Environment using Dockers. Set the …

Continue reading

Posted in Javascript. Tagged with .

Javascript – How to Get Started with JSCS

This article represents tips on how to get started with JSCS, a Javascript code styler checker tool. The tool comes very handy if you would want to ensure the consistent code formatting across the team. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: Install/Setup JSCS Run JSCS & Code Samples Install/Setup JSCS One could install jscs using command such as “npm install -g jscs”. You could also setup Javascript development environment using Dockers as detailed in this page. Once installed, all that is required to be done is …

Continue reading

Posted in Javascript. Tagged with .

AngularJS – 6 Tips to Optimize the Digest Cycle

This article represents tips on making optimal usage of digest cycle which slowers the Angular app. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points in relation with optimization of Digest cycle: Only the most critical variables should be watched. For instance, one should avoid using $digest method in loop for every message exchanged. Usage of one-time binding syntax to avoid objects being added to $$watchers list and thus being checked for updates with each $digest run. The syntax looks like {{::name}}. With this syntax, once the name variable is resolved, Angular removes the name …

Continue reading

Posted in Javascript. Tagged with .

Dockers – How to Get Started with Spark on Windows

This article represents tips on how to get started with Apache Spark on Windows using Dockers. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. If you are familiar with Dockers, the instructions below would help you get started with Spark in no time. Download the Spark from https://spark.apache.org/downloads.html page. Remember to select a package type with option such as “Pre-built…”. Once the zipped files are downloaded, unzip the files under the location “C:\Users\<Username>” Build Java8 image and start the container. Follow the instructions on this page, http://vitalflux.com/dockers-how-to-get-started-with-java8-dev-environment/. Once the container is started, go to the folder where you …

Continue reading

Posted in Big Data, Dockers. Tagged with , .

Dockers – How to Get Started with Java8 Dev Environment

This article represents take away code samples and tips on how to setup Java8 container using Dockers and get started. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: Java 8 Image Dockerfile Install Scripts to Install and Start Java8 Env   Java 8 Image Dockerfile Following is Dockerfile for creating Java8 image. Name the file as java8_base.df. # Base is the Centos environment FROM centos:centos6 # Make the directories under which Java 8 will get installed RUN mkdir /opt/jdk RUN cd /opt # Install wget and tar which …

Continue reading

Posted in DevOps, Dockers, Java. Tagged with , , .

Ionic App – Automated Release APK Creation – Shell Commands

This article represents code samples which could be used to automate Ionic App release APK file creation further to which this APK file can be uploaded to Google Playstore and released. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Commands to Automate Building Ionic App Release APK Copy and paste following commands in a file named as release.bat. When ready to release, execute “release.bat” on the command prompt and you should have an APK file created for releasing it to playstore. Following are key points to be noted: Before executing below commands, one would be required to create …

Continue reading

Posted in Mobility. Tagged with .

NodeJS – How to Create & Instantiate a Class – Code Samples

This article represents tips and code samples on How to create and instantiate a Class in NodeJS. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: How to Create a Class? How to Instantiate a Class? How to Create a Class? // This is a Constructor function taking age and passport // as the paramaters function Person(age, passport) { this.age = age; this.passport = passport; } // Sets the age // Person.prototype.setAge = function(age) { this.age = age; }; // Checks whether the person is Adult based on the …

Continue reading

Posted in Javascript. Tagged with , .

Code Samples on NodeJS Module.Exports

This article represents code samples on NodeJS Module.exports. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Code Sample for a NodeJS Module using Module.Exports Save the code as “room.js”. module.exports = { windowsCount: 0, doorsCount: 0, LARGEROOM: {doorsCount: 2, windowsCount: 2}, SMALLROOM: {doorsCount: 1, windowsCount: 1}, getDoorsCount: function () { return ++this.doorsCount; }, getWindowsCount: function() { return ++this.windowsCount; }, isLargeRoom: function(config) { if(config.doorsCount >= this.LARGEROOM.doorsCount && config.windowsCount >= this.LARGEROOM.windowsCount) { return true; } return false; }, isSmallRoom: function(config) { if(config.doorsCount <= this.SMALLROOM.doorsCount && config.windowsCount <= this.SMALLROOM.windowsCount) { return true; } return false; } }; Code to Execute Module …

Continue reading

Posted in Javascript, Web. Tagged with , .

Javascript – Module, Module.Exports & related Best Practices

This article represents definition and code samples on how to modularize Javascript functions and use them elsewhere in different Javascript file. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key points described later in this article: What is Module? What is Module.exports? Test the Module   Module: A unit encapsulating similar functions or a piece of code representing similar functions. For example, take a look at following code: var drawTraingle = function() { console.log(“Traingle drawn”); } var drawCircle = function() { console.log(“Circle drawn”); } Above code could be saved as draw.js. The file draw.js could …

Continue reading

Posted in Javascript. Tagged with , .

Code Samples to SSH into Docker Machine Virtualbox

This article represents quick code sample which would help you ssh into a docker machine. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. As you double-click Docker Quickstart Terminal, it opens up a terminal window thereby starting “default” docker-machine. If you want to login to this docker-machine, you could do that using following: Use Putty to login. As you open Putty, enter the IP such as 192.168.99.100 and click open. It would open up a terminal. Enter “docker” as username and “tcuser” as password and that is it. Use command such as “docker-machine ssh default” in the docker …

Continue reading

Posted in DevOps, Dockers. Tagged with .

5 Steps to Release Your Ionic App to Google Playstore

This article represents tips/steps and code sample which can be used to release your ionic app on Google playstore. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Create Release Build Following command can be used to create release build for Android. This will generate a release build based on the settings in your config.xml. For every new release, you may want to change the version in config.xml file. cordova build –release android By executing above command in the home directory, one could find generated apk file with name such as android-release-unsigned.apk in the path platforms/android/build/outputs/apk. Create One-time Private …

Continue reading

Posted in Android, Mobility. Tagged with , , .

Atom IDE – My Favorite Top 10 Keyboard Shrotcuts

This article represents a list of my favourite keyboard short-cuts for Atom IDE. Please feel free to comment/suggest if you thought that one or more short-cuts could be included. Also, sorry for the typos. Following is the list of my favourite top 10 keyboard short-cuts which I use very frequently when writing the code using ATOM IDE. Ctrl + Space: Show available auto-completions. For example, type “ul” and press CTRL + Space bar, and it would print <ul></ul> Ctrl + /: Comment a selection. Find operations Ctrl + p: Toggle file finder. Opens up a dialog box with a textfield which can be used to find/search a file. Ctrl + …

Continue reading

Posted in Tools, Web. Tagged with .

Ionic Framework – How to Create an Ionic App without Side Nav Menus

This article represents tips and code samples on creating an ionic app without side menus. Note the “menu.html” and “login.html” file for the code to include appropriate header text. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos. Following are the key files required to make such an Ionic App: App.js to manage states Controllers.js to include controllers Menu.html to include code related with navigation Login.html to include code specific to login page App.js to Manage States Make sure your app.js looks like following. Place the file in www/js folder. angular.module(‘starter’, [‘ionic’, ‘starter.controllers’ ]) .run(function($ionicPlatform) { $ionicPlatform.ready(function() { // …

Continue reading

Posted in Mobility. Tagged with , .

9 Linux Foundation Projects for IOT, Cloud, Big Data

This article represents top Linux foundation projects in relation with IOT, Cloud and Big Data. With the convergence of these three technology domains, it becomes of utmost important to keep a track of news/announcements happening in these areas. The reference of all the projects could be found on this page. Following are the key linux foundation projects in relation with IOT, Cloud and Big Data. IOT (Internet of Things) AllSeen Alliance: A cross-industry consortium dedicated to enabling interoperability of billions of devices, services and apps that comprise the internet of things (IOT). Bookmark announcements and news for latest information. IoTivity: An open-source software framework enabling seamless device-to-device connectivity to address …

Continue reading

Posted in Big Data, Cloud, IOT. Tagged with , , .