Skip to content

Instantly share code, notes, and snippets.

View vishnu-saini's full-sized avatar

Vishnu Saini vishnu-saini

View GitHub Profile

Redux Notes

What is Redux

Redux is one of the hottest libraries for front-end development in today’s marketplace. It is a predictable state container for JavaScript applications and is used for the entire applications state management. Applications developed with Redux are easy to test and can run in different environments showing consistent behaviour image

Three principles of Redux

  • Single source of truth: The state of the entire application is stored in an object/ state tree within a single store. The single state tree makes it easier to keep track of changes over time and debug or inspect the application.
  • State is read-only: The only way to change the state is to trigger an action. An action is a plain JS object describing the change. Just like state is the minimal representation of data, the action is the minimal representation of the change to that data.
  • **Changes are
# Setting up react application
• Update npm to npm6+
npm install -g npm
• Setting up a basic react application
npm init react-app ptim-app
• Setting up material ui in react app

Linting - Linting is the process of checking the source code for Programmatic as well as Stylistic errors. This is most helpful in identifying some common and uncommon mistakes that are made during coding. ESlint is a JavaScript linting tool. Prettifying – formatting the code (similar to ctrl+shift+f in eclipse). Prettier is a well know prettifying tool in JavaScript community.

Integrating Eslint & Prettier in React

  1. Installing and using ESlint in a JavaScript project. (Specific to JS project)

https://eslint.org/docs/user-guide/getting-started

  1. Installing and using ESlint along with Code prettier in a react-redux application and extending Airbnb’s style guide.

Concurrency

Concurrent applications also make optimal use of the processors. But concurrent applications are difficult to develop, maintain, and debug. To develop thread-safe, high-performance, and scalable applications, Java’s low-level threading capabilities are insufficient.

Concurrent collection classes

The java.util.concurrent package includes a number of additions to the Java Collections Framework. These are most easily categorized by the collection interfaces provided:

  • BlockingQueue defines a first-in-first-out data structure that blocks or times out when you attempt to add items to a full queue, or retrieve from an empty queue.
import React, {Component} from "react";
import ReactDOM from "react-dom";
export default class PartialMatchFilter extends Component {
constructor(props) {
super(props);
this.state = {
text: ''
};

Data Structures

  • Array
  • Linked List
  • Stack
  • Queue
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Hashing

Java Inner Class

Java inner class is defined inside the body of another class. Java inner class can be declared private, public, protected, or with default access whereas an outer class can have only public or default access.

Java inner classes are divided into 4 categories

  • Static inner class
  • Non-static java inner class
  • Method local inner class
  • Anonymous inner class

Static inner class

When port is not free (8080 or other)

  You can use "netstat" to check whether a port is available or not.
  ```
  netstat -ano | findstr 8080
  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       6696
  TCP    [::]:8080              [::]:0                 LISTENING       6696
  ```
  then kill the process with 

Threads

Have you ever watched a movie with a group of friends, laughing, shouting, and sharing popcorn, nachos, or fries—all at the same time? If yes, you’ve already practiced multithreading and concurrency.

“Every problem has a solution, and every solution has a problem”—this statement holds true for threads. Threads were created so that they could make the best use of a processor’s time. An application can create multiple threads. When threads share objects among themselves, it can result in interleaving operations (thread interference)