Wednesday, August 15, 2018

How to set up webpack for a project?

In one of my project I needed to work with webpack and for this I need to install webpack and other dependency modules using npm package as follows:

npm init
npm install --save-dev webpack webpack-dev-server

in above two commands the first one is to set up node package configuration file the package.json to install node modules.

And the second line is to install depedency modules like webpack and webpack-dev-server which is the developement server to test the application locally.

Tuesday, August 7, 2018

Angular Style Guide

It is good practice to update yourself when needs. Recent I have been working in an angular project so it is important to update myself with the style guide of angular. I have found a tutorial from angular official site as follows:

https://angular.io/guide/styleguide

it may help me or you later :)

AngularJs Style Guide

Recent I have come up with my angularJs knowledge shaping up with a style guide. I have found a tutorial to make it possible as follows:

https://github.com/toddmotto/angularjs-styleguide

it may help me or someone later :)

Saturday, July 21, 2018

FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformClassesWithDexBuilderForDebug'. > java.io.IOException: Could not delete path

I was working in a ReactNative project and while setting up it's environment was getting error as follows:

FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformClassesWithDexBuilderForDebug'. > java.io.IOException: Could not delete path


After removing the build directory from root directory -> android -> app 

it just did the trick :)

Error: Incompatible HAX module version 3, requires minimum version 4 in Android Studio


Sometimes it is needed to create virtual device while working on android studio that I did on working in an android project. But when tried to launch the device some errors occurred as follows:

Emulator: Incompatible HAX module version 3, requires minimum version 4
Emulator: No accelerator found.
Emulator: failed to initialize HAX: Invalid argument

So found the solution to sort this out as follows:

Steps:

Android Studio: Tools -> SDK Manager

Under Default Settings:

Appearance & Behavior -> System Settings -> Android SDK:

You should see “Android SDK Location” with text field. Copy that location and search through in your windows explorer. For me the location is: “C:\Users\YourUser\AppData\Local\Android\Sdk” in this location navigate through other segment like: 

\extras\intel\Hardware_Accelerated_Execution_Manager so the full path is: 

C:\Users\YourUser\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager

And there find the file name “intelhaxm-android.exe” and click on it to install. 

After installing it launch again the AVD device.

Cool! It’s done J

Wednesday, July 18, 2018

Sort array of objects by property name in javascript

I was working with javascript sort method to sort out an array of objects with a scenario like I needed to sort by object property 'name' but using only sort method didn't fullfill my requirements so I came with additional method implemented as a middleware of sort method like below:

Current Result:
const objArray = [
{ name: 'Z', age: 32},
{ name: 'B', age: 23},
{ name: 'C', age: 45},
{ name: 'E', age: 33},
{ name: 'A', age: 53}
];

Expected result:
const objArray = [
{ name: 'A', age: 53}
{ name: 'B', age: 23},
{ name: 'C', age: 45},
{ name: 'E', age: 33},
{ name: 'Z', age: 32}
];

objArray.sort(sortBy('name', false));


function sortBy(key, reverse) {
 var moveSmaller = reverse ? 1 : -1;
 var moveLarger = reverse ? -1 : 1;
 return function(a, b) {
  if (a[key] < b[key]) {
    return moveSmaller;
  }
  if (a[key] > b[key]) {
    return moveLarger;
  }
  return 0;
 };
 
}

It may help someone like me :)

Tuesday, June 5, 2018

Some necessary git commands

While working on git I had to follow some git commands to execute some tasks which are following:

git Add -A //(add to stage)

git commit 'message' //(commit stage files)

git commit -am 'message' //(add to stage and commit stage files in one command)

git push origin branchName //(push all your local changes to production in specific branch)

git branch branchName //(create branch)

git checkout master //(switch branch to master branch)

git merge branchName //(merge specific branch with selected branch)

git pull origin master //(pull changes from master branch from production)

git branch //(list all created branch)

git branch -d branchName //(delete a specific branch)

git checkout -b branchName //(create and switch to a specific branch in one command)

Hope it may helps someone or me later :)