Thursday, June 29, 2017

JavaScript Recipe: Round to a number of decimal places stripping trailing zeros

JS uses binary floating point to handle decimal based operations.
JavaScript calculations with floating point causes the Nonsense cases especially during the result comparisons & displaying.
If the variable was created as a Number, not a String, extra trailing zeros would be dropped automatically.
Friday, March 31, 2017

Angular recipe: Get State updates from Redux

This article is about the possible ways to retrieve your data State in Angular (read 2 or 4) from Redux Store.


It's assumed that you are already familiar with Redux ecosystem. If not click an image below:

Wednesday, March 8, 2017

Pair your Total Commander file manager with Cmder console

Do you want to feel yourself as happy on Windows as on Mac? Well, sleek console and good file-manager could help you a lot...

Cmder


Cmder is a powerful console emulator for Windows.

Here is a short tip how to pair you Cmder Console with Total Commander file manager.
Monday, March 6, 2017

Keynote: Quick Creation of Angular2 App

This article is about fast setup & start working on your ng2 application.


The process feels quite similar to Node modules creation through npm CLI commands, but here we will use Angular Command Line Interface (Angular-CLI).

Thursday, March 2, 2017

Keynote: Quick Creation of Node.js Module

This is short note about fast creation, publishing & using Node.js module via using Command Line Interface.
  • Use npm init to create package.json.
  • Run npm install --save to install dependency and save it to package.json.
When the code in the foo package does require('bar'), it will be loaded either foo/node_modules/bar or from core modules if it was installed as a global module via nmp install -g command.
Monday, February 27, 2017

Git tips & tricks: Merge vs Rebase (When to use?)

Keeping a clean history and smooth git workflow comes down to knowing the base use-cases & rules.
Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards.

  • Use git pull --rebase when pulling changes from origin.
  • Use git merge when merging feature branch changes back to master.
Rebasing Deletes Merge Commits! Never rebase master onto your feature branch!
see also –preserve-merges flag.
Using merge when pulling changes from origin ties two histories together creating interleaved messy thread of histories:
  • Interleaved history during merge: their feature X, my feature Y, their feature X, my feature Y...
  • Linear history during rebase: their feature X, their feature X, my feature Y, my feature Y...
Monday, January 30, 2017

Java recipe: Initialize an ArrayList with zeros

It's often useful to have a list filled with zeros of the specified length N.
Why would you want one? Well, it's handy during the work with algorithms, or just to avoid null checks.
Usually, instead of the List filled with 0s an Array is enough: new int[N]
- creates an array of N integers with zero value.
new ArrayList(N) (has the size 0) is NOT the same as new int[N] (has the length N)

- The integer passed to the constructor of list represents its initial capacity (the number of elements it can hold before it needs to resize its internal array) which has nothing to do with the initial number of elements in it.
Whatever, below are the bunch of ways to create the List filled with zeros, if you need one.
In each example we will create a list filled with 100 zeros. (Java8 implementation with StreamAPI included).