Posts

Showing posts from June, 2017

Angular - Good to know facts for developers

Setup angular app Setup  here No restarting your application while development. npm start This command runs the Typescript compiler in "watch mode" - ie any changes you make to your code will automatically get reflected in the browser. Your code will get launched and when changes are made, the browser will refresh and display your changes. Manage dependencies using npm Simply manage all your angular and angular app dependencies using npm - node package manager. node.js and npm are essentials for angular development, get them if you dont already have them. Separate devdependencies and dependencies With Angular you can have separate development dependencies and separate deployment dependencies. You no longer need to worry about packaging you dev dependencies. angular-in-memory-web-api It is an angular-supported library. You don't need an actual server or real HTTP calls. You can simulate the behavior using this library. bootstrap A pop

Your own Thread Pool

"Create your own thread pool" - A typical interview question, asked to check if you have a basic understanding of Thread Pool, Runnable, and the disadvantages of creating a new Thread for each Task. ThreadPool is made up of a number of threads, identified by the core thread pool size. Once you start the ThreadPool, all the threads start running, waiting for the task. Each task or Runnable that you submit to the ThreadPool is executed by the existing threads of the ThreadPool. Creating a thread is expensive, so it is advisable to have a ThreadPool which manages the tasks. Here is a program which creates its own ThreadPool - MyThreadPool. import java.util.concurrent.ArrayBlockingQueue ; import java.util.concurrent.BlockingQueue ; class MyThreadPool { private int corePoolSize ; private MyThread tPool []; private BlockingQueue < Runnable > queue = new ArrayBlockingQueue <>(1024); public MyThreadPool ( int corePoolSize ) { thi

Ejabberd Client Guide

In this post, we are going to look at a quick guide to build a client for Ejabberd Server. I have used Smack API . Other available APIs can be found here . Here you have links for web based, python, c++ etc client etc. Please note this post just gives you pointers to move ahead in your development. Before we start with the example, let us first understand what XMPP protocol is. XMPP stands for e X tended M essaging and P resence P rotocol. It is a open standard, decentralized, secure extensible, flexible and diverse protocol for messaging and presence. XMPP Message looks like this: <message to= 'romeo@example.net' from= 'juliet@example.com/balcony' type= 'chat' xml:lang= 'en' > <body> Wherefore art thou, Romeo? </body> </message> It is based on XML. It enables near real time exchange of structured yet extensible data between any two or more network entities. Originally named Jabber, it was

Different ways to create an Object in Java

In this post, we will discuss the different ways to create a new Object Consider we have a class, say CustomClass and we are going to see different ways in which we can create a new object of CustomClass. Using new keyword/the constructor: new CustomClass (); Clone You already have an object and you using Cloning to create a copy of that object CustomClass myObject = new CustomClass (); CustomClassobject = ( CustomClass ) myObject . clone (); Class.forName: The reflection API gives us the ability to create objects without calling the constructor. Spring and Hibernate use reflection to create objects. Class . forname ( CustomClass ); Deserialization is another way of creating the object. First you serialize and then deserialize to get the object.

Address Book - Part 5 ( CSS Styling our Angular app )

Image
In the previous post , our contact list looked like this: Looks very mundane. Let us beautify our Address Book. CSS styling is the way to go!  There are different ways to add styling to our angular app. Make changes in the style.css file in the src folder. This will be applied across the entire app ie global. Adding the style tag to the specific component ..... @ Component({ selector : 'contacts' , templateUrl : './contacts.html' , styles : [ ` .contactList { padding: 0 ; } .contactList li{ list - style - type: none ; padding: 0.25em ; width: 15em ; cursor: pointer ; background - color: lightblue ; color: navy ; border: 0.01em solid lightgrey; border - radius: 0.2em ; text - align: left ; margin: 0.5em ; } .contactList li: hover { background - color: dodgerblue ! important; color: white ; } .contactList li.selected: hover { background - color: yellow ; } ` ] }) export class Con