Friday, May 26, 2017

converting json structure to circular error

I faced this error while having a react js web application requesteing data from backend services which talk to our rethinkdb database.

The root cause was there were no tables created in the database and backend services are requiringn these tables to process the request.

So after creating the data tables and inserting data into the tables I was able to solve the error.

Tuesday, May 23, 2017

Import and require difference in react

Require:
This allows us to have dynamically load module which isnt predefined or we can also conditionally load  a module when we reuire it.
Ex: var Navitem =require ("./components/NavItem");
Imports:
We can use ES6 import to selectively load the pieces which we need and by doing this we can save memory.
import Navitem from("./components/NavItem);


require is in ES 5 and in ES 6 we make use of import

Monday, May 22, 2017

Soft link and hard link in linux

Soft link has a different inode number and original file has different number. Soft link can link to a directory and the link will not have original file but shows the path.

Hard link has same inode number and will have original file contents. Removing the links will not affect original file contents. We cannot create a hard link to a directory.

Wednesday, May 17, 2017

How to know password for a wifi you connected previously, in case if you forgot and need to connect another device

The following is for windows.

Open command prompt and run it as administrator

Enter the following command

netsh wlan show profile

This command lists all the network names you have connected and remembered.




then enter the above command along with wifi name and key=clear

netsh wlan show profile netgear72 key=clear

This would display various profile properties in which we can find the password, look out for key content.



Monday, May 15, 2017

React js

React is a javascript library which can be used to develop user interfaces. We can also use it to develop complex and amazing web apps. It can be also be combined with Redux and many other tools to develop amazing applications.

Saturday, May 13, 2017

Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.

public class Solution {
    public int minDistance(String word1, String word2) {
        if (word1.equals(word2)) {
        return 0;
    }
    if (word1.length() == 0 || word2.length() == 0) {
        return Math.abs(word1.length() - word2.length());
    }
    int[][] dp = new int[word1.length() + 1][word2.length() + 1];
    for (int i = 0; i <= word1.length(); i++) {
        dp[i][0] = i;
    }
    for (int i = 0; i <= word2.length(); i++) {
        dp[0][i] = i;
    }
    for (int i = 1; i <= word1.length(); i++) {
        for (int j = 1; j <= word2.length(); j++) {
            if (word1.charAt(i - 1) == word2.charAt(j - 1)) {
                dp[i][j] = dp[i - 1][j - 1];
            } else {
                dp[i][j] =Math.min(dp[i-1][j], dp[i][j-1]) + 1;
            }
        }
    }
    return dp[word1.length()][word2.length()];
    }
}

Output:
"sea"
"eat"

Answer:
2

Friday, May 12, 2017

express module node.js

Express module is one of the most installed module in Node.js.  Express is a flexible Node.js web application framework which provides a robust set of features for web as well as mobile applications.
Using express we can create robust API's very easily and quickly .

Thursday, May 11, 2017

NPM (Node.js package manager)

NPM comes with node.js installation. It is node.js package manager, as the name suggests it is used to install node programs/modules. We can also easily specify and link dependencies.

npm install express                                installs express module

npm install express --save                     installs express and updates the dependencies in package.json


Modules get installed into the "node_modules" folder .

Wednesday, May 10, 2017

package.json in Node.js

This file goes in the root of our package or application and it tells how our package is structured and what to do to install it.

"npm init" command will create a package.json file and it will ask for details as shown below



Tuesday, May 9, 2017

Partial Classes

Partial classes concept was introduced in .NET 2.0 which allows us to split business logic in multiple files with same class name but with a "partial" keyword.

Monday, May 8, 2017

Explain the differences between TCP and UDP?

Tcp is connection oriented service which means every time you send a message you get an acknowledgment from the receiver stating the message has been received.
This is a reliable way of communication, but is slow. Think of it as a telephonic call. Only when the other side picks up the call, you can talk.

UDP is connectionless service. Like the one we use in online streaming. There is no acknowledgement in this case so the data might not be perfect at the receiver but the transmission is fast. So a few packet loss doesn't really matters. It is like an email. You can send but you wont know if it has been read or not. Like you wont know which packets reached and which were dropped.

Sunday, May 7, 2017

constant and read only difference in C#

constant needs to be initialized when it is declared.

read only variable can be assigned dynamically but need to be done before constructor exists as the the value is not changeable later.


Choosing between  read only or constant depends on our requirement. When we are confident that our constant value does not change we can use "const". The issue with constant is when we define a constant "a" variable with value 20 in an assembly X and use this assembly in another assembly Y, any update of variable "a" is not reflected until we recompile it.

But when we use a read only value here it is a reference to memory location and when we have new "a" value and on building assembly "X" all the assemblies using this X assembly the value of "a" is updated without being building them again.

Saturday, May 6, 2017

Software Testing

Verification and Validation of a software can be considered as Software Testing.

Tuesday, May 2, 2017

object literals in Javascript

A JavaScript object literal is like a comma separated name value pairs .

 Ex: var myObject={name:"narendra",height:180};

We can access the properties as myObject.name which gives "narendra"

Monday, May 1, 2017

Truthy and falsy values

Truthy Values:

"0"
"false"
empty functions
empty arrays
empty objects
typeof(null)

these above listed items are considered true in javascript


Falsy values:

false
0
""
null
undefined
NaN(Not a number)

These are considered false.

When dealing with these truthy and falsy values we should be careful and always try to use "===" or "!==" when we need to compare .

Call a function in child component from parent component in React

Consider the following parent component class Parent extends React.Component { constructor(props) { super(props);         thi...