├── CNAME ├── _sass └── custom │ └── custom.scss ├── docs ├── java │ ├── images │ │ ├── hashing.png │ │ ├── Exceptions.png │ │ ├── Life-Cycle-Thread.png │ │ ├── hashMap-internal.png │ │ ├── Shallow-Vs-Deep-cloning.png │ │ └── intermediate and terminal operations.png │ └── java17.md ├── ui │ ├── react │ │ ├── assets │ │ │ ├── dom.png │ │ │ ├── flux.png │ │ │ ├── mvc.png │ │ │ ├── star.png │ │ │ ├── flux-2.png │ │ │ ├── redux.png │ │ │ ├── redux-2.png │ │ │ ├── context-api.jpg │ │ │ ├── forwardRef.png │ │ │ ├── props-state.jpg │ │ │ ├── react-fiber.png │ │ │ ├── react-form.png │ │ │ ├── react-hooks.png │ │ │ ├── react-logo.gif │ │ │ ├── react-redux.png │ │ │ ├── react-sight.png │ │ │ ├── react-store.png │ │ │ ├── redux-cycle.png │ │ │ ├── redux-saga.png │ │ │ ├── redux-setup.png │ │ │ ├── redux-state.png │ │ │ ├── shadow-dom.png │ │ │ ├── stack-trace.png │ │ │ ├── component-tree.png │ │ │ ├── flux-structure.png │ │ │ ├── react-features.png │ │ │ ├── react-roadmap.png │ │ │ ├── react-routing.png │ │ │ ├── reconciliation.jpg │ │ │ ├── redux-and-flux.png │ │ │ ├── redux-devtool.png │ │ │ ├── redux-thunk.jpeg │ │ │ ├── redux-workflow.png │ │ │ ├── service-worker.png │ │ │ ├── todo-project.png │ │ │ ├── react-dev-tools.png │ │ │ ├── react-lifecycle.png │ │ │ ├── react-redux-form.png │ │ │ ├── redux-components.jpg │ │ │ ├── redux-data-flow.gif │ │ │ ├── useLayoutEffect.png │ │ │ ├── flux-architecture.png │ │ │ ├── poketimes-project.png │ │ │ ├── react-architecture.png │ │ │ ├── redux-architecture.png │ │ │ ├── virtualdom-vs-realdom.png │ │ │ ├── Higher-Order-Components.jpg │ │ │ ├── react-native-architecture.jpg │ │ │ └── react-twoway-data-binding.png │ │ ├── images │ │ │ ├── flux.png │ │ │ ├── logo.jpeg │ │ │ ├── phases.png │ │ │ ├── state.jpg │ │ │ ├── vdom1.png │ │ │ ├── vdom2.png │ │ │ ├── vdom3.png │ │ │ ├── vdom4.png │ │ │ ├── vdom5.png │ │ │ ├── devtoolsTab.png │ │ │ ├── phases16.3.jpg │ │ │ ├── phases16.4.png │ │ │ ├── error_boundary.png │ │ │ └── devtoolsInspect.png │ │ ├── props.md │ │ ├── state.md │ │ └── events.md │ ├── angular │ │ ├── images │ │ │ ├── anular-pipes.png │ │ │ ├── Types-of-Pipes.png │ │ │ ├── angular-logo-1.png │ │ │ ├── angular-component.png │ │ │ ├── dom-manipulation.png │ │ │ ├── lifecycle-hooks.webp │ │ │ ├── 2.1-wildcard-route.png │ │ │ ├── 2.2-wildcard-route.png │ │ │ ├── 7.1-department-list.png │ │ │ ├── types-of-directives.png │ │ │ ├── Attributes-Directives.png │ │ │ ├── student-table-output.png │ │ │ ├── 4.2-route-parameters-next.png │ │ │ ├── 1.1-spa-single-page-app-home.png │ │ │ ├── 4.1-route-parameters-previous.png │ │ │ ├── 1.4-spa-single-page-app-products.png │ │ │ ├── 1.3-spa-single-page-app-employees.png │ │ │ ├── 4.3-route-parammap-observable-next.png │ │ │ ├── 5.1-optional-route-parameters-back.png │ │ │ ├── 7.3-child-route-department-contact.png │ │ │ ├── 1.2-spa-single-page-app-departments.png │ │ │ ├── 7.2-child-route-department-overview.png │ │ │ ├── 3.2-route-parameters-department-clicked.png │ │ │ ├── 1.5-spa-single-page-app-folder-structure.png │ │ │ ├── 3.1-route-parameters-department-list-home.png │ │ │ ├── 7.4-optional-route-param-active-highlight.png │ │ │ ├── difference-between-directives-components.png │ │ │ └── 5.2-optional-route-parameters-selected-list.png │ │ ├── angular-lazy-loading.md │ │ ├── angular-data-binding.md │ │ ├── sample.md │ │ ├── angular-services.md │ │ ├── angular-cli.md │ │ ├── angular-pipes.md │ │ ├── angular-http-interceptor.md │ │ └── angular-lifecycle-hooks.md │ ├── vue │ │ └── vuejs.md │ └── ui.md ├── algorithms │ ├── images │ │ ├── Sudoku.png │ │ ├── Platforms.png │ │ ├── Parentheses.png │ │ ├── binaryTreeEx1.png │ │ ├── binaryTreeEx2.png │ │ ├── binaryTreeSol1.png │ │ ├── KadaneAlgorithm.png │ │ ├── String │ │ │ ├── complexity.png │ │ │ ├── groupAnagram.png │ │ │ ├── Ex1ofWordSearch.png │ │ │ ├── Ex2ofWordSearch.png │ │ │ ├── Ex3ofWordSearch.png │ │ │ ├── groupAnagram1.png │ │ │ ├── sortTheDifference.png │ │ │ ├── hashmapTheDifference.png │ │ │ ├── findTheDifferenceSolution3.png │ │ │ ├── Ex1_ValidateBinarySearchTree.png │ │ │ └── Ex2_ValidateBinarySearchTree.png.png │ │ ├── integer │ │ │ ├── recursion.png │ │ │ ├── addTwoNumbers.png │ │ │ ├── mathFibonacci.png │ │ │ ├── ValidMountainsEx.png │ │ │ ├── MatrixExponentiation.png │ │ │ ├── PerfectNumOptimalSol.png │ │ │ └── solutionAddTwoNumbers.png │ │ ├── FindDuplicateArray.png │ │ ├── NumDisappearInArray1.png │ │ ├── NumDisappearInArray2.png │ │ ├── array │ │ │ ├── WaterContainerEx.png │ │ │ ├── TrappingRainWaterEx.png │ │ │ ├── MaxConsecutiveOnesSol1.png │ │ │ └── BestTimetoBuyandSellStock.png │ │ ├── binaryTreecomplexity.png │ │ └── LinkedList │ │ │ ├── Ex1OfReverseLinkedList.png │ │ │ └── Ex2OfReverseLinkedList.png.png │ ├── sorting.md │ └── queue.md ├── nodejs │ ├── images │ │ ├── Event Loop.png │ │ └── Node-work.png │ └── Nodejs.md ├── oops │ └── images │ │ ├── Association.png │ │ ├── Composition.png │ │ ├── two-way association.png │ │ ├── default-methods-error.png │ │ ├── Association vs. Aggregation vs. Composition.png │ │ └── aggregation between a professor and department.png ├── spring │ ├── images │ │ ├── JpaRepositoryUml.png │ │ └── spring-mvc-flow.png │ ├── security │ │ ├── images │ │ │ ├── Figure1-FilterChain .png │ │ │ ├── ExceptionTranslationFilter.png │ │ │ ├── Figure 3. FilterChainProxy .png │ │ │ ├── Figure 2. DelegatingFilterProxy .png │ │ │ ├── Figure 4. SecurityFilterChain .png │ │ │ └── Figure 5. Multiple SecurityFilterChain .png │ │ └── security.md │ ├── spring-cloud.md │ ├── spring-security.md │ ├── swagger-docs.md │ └── spring-batch.md ├── kafka │ └── images │ │ └── kafka-message-flow.jpeg ├── microservices │ └── images │ │ ├── API-Gateway.png │ │ ├── Encoded JWT Claim.png │ │ ├── Config Server Architecture.png │ │ ├── Eureka Registry Screenshot.png │ │ ├── microservice-architecture.png │ │ ├── CircuitBreakerImplementation.png │ │ ├── High Level Eureka Architecture.png │ │ ├── Client Crendtials Sequence Diagram.png │ │ ├── Five Grants in OAuth 2.0 protocol.png │ │ ├── 2pc rollback for the customer order .png │ │ ├── Beehive-Representation-Microservices.png │ │ ├── OAuth2 Use in Microservices Context.png │ │ ├── Saga pattern for the customer order.png │ │ ├── Different Layers in a Single Microservice.png │ │ ├── customer order example with microservices.png │ │ ├── 2pc implementation for the customer order .png │ │ ├── Best Practices in Microservices Architecture.png │ │ ├── Four different roles in OAuth 2.0 protocol.png │ │ ├── Saga pattern for a compensation transaction.png │ │ └── monolithic system using a local transactio.png ├── devops │ ├── images │ │ └── Docker architecture.png │ ├── devops.md │ ├── maven.md │ ├── kubernetes.md │ └── linux.md ├── misc │ ├── misc.md │ ├── behavioral-situational.md │ ├── git.md │ ├── http.md │ └── production.md ├── company │ └── company.md ├── graphql │ └── graphql.md ├── aws │ ├── ec2.md │ └── api-gateway.md ├── system-design │ └── system-design.md └── database │ ├── mongo-db.md │ └── hibernate.md ├── .idea ├── misc.xml ├── vcs.xml ├── .gitignore ├── modules.xml ├── interview-docs.iml └── sonarlint │ └── issuestore │ └── index.pb ├── .gitignore ├── sitemap.xml ├── README.md └── _config.yml /CNAME: -------------------------------------------------------------------------------- 1 | interview-docs.com -------------------------------------------------------------------------------- /_sass/custom/custom.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/java/images/hashing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/hashing.png -------------------------------------------------------------------------------- /docs/ui/react/assets/dom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/dom.png -------------------------------------------------------------------------------- /docs/ui/react/assets/flux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/flux.png -------------------------------------------------------------------------------- /docs/ui/react/assets/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/mvc.png -------------------------------------------------------------------------------- /docs/ui/react/assets/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/star.png -------------------------------------------------------------------------------- /docs/ui/react/images/flux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/flux.png -------------------------------------------------------------------------------- /docs/java/images/Exceptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/Exceptions.png -------------------------------------------------------------------------------- /docs/ui/react/assets/flux-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/flux-2.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux.png -------------------------------------------------------------------------------- /docs/ui/react/images/logo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/logo.jpeg -------------------------------------------------------------------------------- /docs/ui/react/images/phases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/phases.png -------------------------------------------------------------------------------- /docs/ui/react/images/state.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/state.jpg -------------------------------------------------------------------------------- /docs/ui/react/images/vdom1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/vdom1.png -------------------------------------------------------------------------------- /docs/ui/react/images/vdom2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/vdom2.png -------------------------------------------------------------------------------- /docs/ui/react/images/vdom3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/vdom3.png -------------------------------------------------------------------------------- /docs/ui/react/images/vdom4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/vdom4.png -------------------------------------------------------------------------------- /docs/ui/react/images/vdom5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/vdom5.png -------------------------------------------------------------------------------- /docs/algorithms/images/Sudoku.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/Sudoku.png -------------------------------------------------------------------------------- /docs/nodejs/images/Event Loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/nodejs/images/Event Loop.png -------------------------------------------------------------------------------- /docs/nodejs/images/Node-work.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/nodejs/images/Node-work.png -------------------------------------------------------------------------------- /docs/oops/images/Association.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/Association.png -------------------------------------------------------------------------------- /docs/oops/images/Composition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/Composition.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-2.png -------------------------------------------------------------------------------- /docs/algorithms/images/Platforms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/Platforms.png -------------------------------------------------------------------------------- /docs/ui/react/assets/context-api.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/context-api.jpg -------------------------------------------------------------------------------- /docs/ui/react/assets/forwardRef.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/forwardRef.png -------------------------------------------------------------------------------- /docs/ui/react/assets/props-state.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/props-state.jpg -------------------------------------------------------------------------------- /docs/ui/react/assets/react-fiber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-fiber.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-form.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-hooks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-hooks.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-logo.gif -------------------------------------------------------------------------------- /docs/ui/react/assets/react-redux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-redux.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-sight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-sight.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-store.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-cycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-cycle.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-saga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-saga.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-setup.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-state.png -------------------------------------------------------------------------------- /docs/ui/react/assets/shadow-dom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/shadow-dom.png -------------------------------------------------------------------------------- /docs/ui/react/assets/stack-trace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/stack-trace.png -------------------------------------------------------------------------------- /docs/ui/react/images/devtoolsTab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/devtoolsTab.png -------------------------------------------------------------------------------- /docs/ui/react/images/phases16.3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/phases16.3.jpg -------------------------------------------------------------------------------- /docs/ui/react/images/phases16.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/phases16.4.png -------------------------------------------------------------------------------- /docs/algorithms/images/Parentheses.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/Parentheses.png -------------------------------------------------------------------------------- /docs/java/images/Life-Cycle-Thread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/Life-Cycle-Thread.png -------------------------------------------------------------------------------- /docs/java/images/hashMap-internal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/hashMap-internal.png -------------------------------------------------------------------------------- /docs/spring/images/JpaRepositoryUml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/images/JpaRepositoryUml.png -------------------------------------------------------------------------------- /docs/spring/images/spring-mvc-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/images/spring-mvc-flow.png -------------------------------------------------------------------------------- /docs/ui/angular/images/anular-pipes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/anular-pipes.png -------------------------------------------------------------------------------- /docs/ui/react/assets/component-tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/component-tree.png -------------------------------------------------------------------------------- /docs/ui/react/assets/flux-structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/flux-structure.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-features.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-features.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-roadmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-roadmap.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-routing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-routing.png -------------------------------------------------------------------------------- /docs/ui/react/assets/reconciliation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/reconciliation.jpg -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-and-flux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-and-flux.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-devtool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-devtool.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-thunk.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-thunk.jpeg -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-workflow.png -------------------------------------------------------------------------------- /docs/ui/react/assets/service-worker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/service-worker.png -------------------------------------------------------------------------------- /docs/ui/react/assets/todo-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/todo-project.png -------------------------------------------------------------------------------- /docs/ui/react/images/error_boundary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/error_boundary.png -------------------------------------------------------------------------------- /docs/algorithms/images/binaryTreeEx1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/binaryTreeEx1.png -------------------------------------------------------------------------------- /docs/algorithms/images/binaryTreeEx2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/binaryTreeEx2.png -------------------------------------------------------------------------------- /docs/algorithms/images/binaryTreeSol1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/binaryTreeSol1.png -------------------------------------------------------------------------------- /docs/kafka/images/kafka-message-flow.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/kafka/images/kafka-message-flow.jpeg -------------------------------------------------------------------------------- /docs/microservices/images/API-Gateway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/API-Gateway.png -------------------------------------------------------------------------------- /docs/oops/images/two-way association.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/two-way association.png -------------------------------------------------------------------------------- /docs/ui/angular/images/Types-of-Pipes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/Types-of-Pipes.png -------------------------------------------------------------------------------- /docs/ui/angular/images/angular-logo-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/angular-logo-1.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-dev-tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-dev-tools.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-lifecycle.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-redux-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-redux-form.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-components.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-components.jpg -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-data-flow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-data-flow.gif -------------------------------------------------------------------------------- /docs/ui/react/assets/useLayoutEffect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/useLayoutEffect.png -------------------------------------------------------------------------------- /docs/ui/react/images/devtoolsInspect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/images/devtoolsInspect.png -------------------------------------------------------------------------------- /docs/algorithms/images/KadaneAlgorithm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/KadaneAlgorithm.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/complexity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/complexity.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/recursion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/recursion.png -------------------------------------------------------------------------------- /docs/devops/images/Docker architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/devops/images/Docker architecture.png -------------------------------------------------------------------------------- /docs/java/images/Shallow-Vs-Deep-cloning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/Shallow-Vs-Deep-cloning.png -------------------------------------------------------------------------------- /docs/oops/images/default-methods-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/default-methods-error.png -------------------------------------------------------------------------------- /docs/ui/angular/images/angular-component.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/angular-component.png -------------------------------------------------------------------------------- /docs/ui/angular/images/dom-manipulation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/dom-manipulation.png -------------------------------------------------------------------------------- /docs/ui/angular/images/lifecycle-hooks.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/lifecycle-hooks.webp -------------------------------------------------------------------------------- /docs/ui/react/assets/flux-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/flux-architecture.png -------------------------------------------------------------------------------- /docs/ui/react/assets/poketimes-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/poketimes-project.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-architecture.png -------------------------------------------------------------------------------- /docs/ui/react/assets/redux-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/redux-architecture.png -------------------------------------------------------------------------------- /docs/algorithms/images/FindDuplicateArray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/FindDuplicateArray.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/groupAnagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/groupAnagram.png -------------------------------------------------------------------------------- /docs/ui/angular/images/2.1-wildcard-route.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/2.1-wildcard-route.png -------------------------------------------------------------------------------- /docs/ui/angular/images/2.2-wildcard-route.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/2.2-wildcard-route.png -------------------------------------------------------------------------------- /docs/ui/angular/images/7.1-department-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/7.1-department-list.png -------------------------------------------------------------------------------- /docs/ui/angular/images/types-of-directives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/types-of-directives.png -------------------------------------------------------------------------------- /docs/ui/react/assets/virtualdom-vs-realdom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/virtualdom-vs-realdom.png -------------------------------------------------------------------------------- /docs/algorithms/images/NumDisappearInArray1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/NumDisappearInArray1.png -------------------------------------------------------------------------------- /docs/algorithms/images/NumDisappearInArray2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/NumDisappearInArray2.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/Ex1ofWordSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/Ex1ofWordSearch.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/Ex2ofWordSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/Ex2ofWordSearch.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/Ex3ofWordSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/Ex3ofWordSearch.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/groupAnagram1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/groupAnagram1.png -------------------------------------------------------------------------------- /docs/algorithms/images/array/WaterContainerEx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/array/WaterContainerEx.png -------------------------------------------------------------------------------- /docs/algorithms/images/binaryTreecomplexity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/binaryTreecomplexity.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/addTwoNumbers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/addTwoNumbers.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/mathFibonacci.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/mathFibonacci.png -------------------------------------------------------------------------------- /docs/microservices/images/Encoded JWT Claim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Encoded JWT Claim.png -------------------------------------------------------------------------------- /docs/ui/angular/images/Attributes-Directives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/Attributes-Directives.png -------------------------------------------------------------------------------- /docs/ui/angular/images/student-table-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/student-table-output.png -------------------------------------------------------------------------------- /docs/ui/react/assets/Higher-Order-Components.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/Higher-Order-Components.jpg -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/algorithms/images/String/sortTheDifference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/sortTheDifference.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/ValidMountainsEx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/ValidMountainsEx.png -------------------------------------------------------------------------------- /docs/ui/react/assets/react-native-architecture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-native-architecture.jpg -------------------------------------------------------------------------------- /docs/ui/react/assets/react-twoway-data-binding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/react/assets/react-twoway-data-binding.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/hashmapTheDifference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/hashmapTheDifference.png -------------------------------------------------------------------------------- /docs/algorithms/images/array/TrappingRainWaterEx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/array/TrappingRainWaterEx.png -------------------------------------------------------------------------------- /docs/spring/security/images/Figure1-FilterChain .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/Figure1-FilterChain .png -------------------------------------------------------------------------------- /docs/ui/angular/images/4.2-route-parameters-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/4.2-route-parameters-next.png -------------------------------------------------------------------------------- /docs/algorithms/images/array/MaxConsecutiveOnesSol1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/array/MaxConsecutiveOnesSol1.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/MatrixExponentiation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/MatrixExponentiation.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/PerfectNumOptimalSol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/PerfectNumOptimalSol.png -------------------------------------------------------------------------------- /docs/algorithms/images/integer/solutionAddTwoNumbers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/integer/solutionAddTwoNumbers.png -------------------------------------------------------------------------------- /docs/microservices/images/Config Server Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Config Server Architecture.png -------------------------------------------------------------------------------- /docs/microservices/images/Eureka Registry Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Eureka Registry Screenshot.png -------------------------------------------------------------------------------- /docs/microservices/images/microservice-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/microservice-architecture.png -------------------------------------------------------------------------------- /docs/ui/angular/images/1.1-spa-single-page-app-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/1.1-spa-single-page-app-home.png -------------------------------------------------------------------------------- /docs/ui/angular/images/4.1-route-parameters-previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/4.1-route-parameters-previous.png -------------------------------------------------------------------------------- /docs/algorithms/images/array/BestTimetoBuyandSellStock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/array/BestTimetoBuyandSellStock.png -------------------------------------------------------------------------------- /docs/java/images/intermediate and terminal operations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/java/images/intermediate and terminal operations.png -------------------------------------------------------------------------------- /docs/microservices/images/CircuitBreakerImplementation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/CircuitBreakerImplementation.png -------------------------------------------------------------------------------- /docs/spring/security/images/ExceptionTranslationFilter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/ExceptionTranslationFilter.png -------------------------------------------------------------------------------- /docs/spring/security/images/Figure 3. FilterChainProxy .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/Figure 3. FilterChainProxy .png -------------------------------------------------------------------------------- /docs/ui/angular/images/1.4-spa-single-page-app-products.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/1.4-spa-single-page-app-products.png -------------------------------------------------------------------------------- /docs/algorithms/images/LinkedList/Ex1OfReverseLinkedList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/LinkedList/Ex1OfReverseLinkedList.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/findTheDifferenceSolution3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/findTheDifferenceSolution3.png -------------------------------------------------------------------------------- /docs/microservices/images/High Level Eureka Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/High Level Eureka Architecture.png -------------------------------------------------------------------------------- /docs/ui/angular/images/1.3-spa-single-page-app-employees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/1.3-spa-single-page-app-employees.png -------------------------------------------------------------------------------- /docs/ui/angular/images/4.3-route-parammap-observable-next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/4.3-route-parammap-observable-next.png -------------------------------------------------------------------------------- /docs/ui/angular/images/5.1-optional-route-parameters-back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/5.1-optional-route-parameters-back.png -------------------------------------------------------------------------------- /docs/ui/angular/images/7.3-child-route-department-contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/7.3-child-route-department-contact.png -------------------------------------------------------------------------------- /docs/algorithms/images/LinkedList/Ex2OfReverseLinkedList.png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/LinkedList/Ex2OfReverseLinkedList.png.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/Ex1_ValidateBinarySearchTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/Ex1_ValidateBinarySearchTree.png -------------------------------------------------------------------------------- /docs/microservices/images/Client Crendtials Sequence Diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Client Crendtials Sequence Diagram.png -------------------------------------------------------------------------------- /docs/microservices/images/Five Grants in OAuth 2.0 protocol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Five Grants in OAuth 2.0 protocol.png -------------------------------------------------------------------------------- /docs/oops/images/Association vs. Aggregation vs. Composition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/Association vs. Aggregation vs. Composition.png -------------------------------------------------------------------------------- /docs/spring/security/images/Figure 2. DelegatingFilterProxy .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/Figure 2. DelegatingFilterProxy .png -------------------------------------------------------------------------------- /docs/spring/security/images/Figure 4. SecurityFilterChain .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/Figure 4. SecurityFilterChain .png -------------------------------------------------------------------------------- /docs/ui/angular/images/1.2-spa-single-page-app-departments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/1.2-spa-single-page-app-departments.png -------------------------------------------------------------------------------- /docs/ui/angular/images/7.2-child-route-department-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/7.2-child-route-department-overview.png -------------------------------------------------------------------------------- /docs/algorithms/images/String/Ex2_ValidateBinarySearchTree.png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/algorithms/images/String/Ex2_ValidateBinarySearchTree.png.png -------------------------------------------------------------------------------- /docs/microservices/images/2pc rollback for the customer order .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/2pc rollback for the customer order .png -------------------------------------------------------------------------------- /docs/microservices/images/Beehive-Representation-Microservices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Beehive-Representation-Microservices.png -------------------------------------------------------------------------------- /docs/microservices/images/OAuth2 Use in Microservices Context.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/OAuth2 Use in Microservices Context.png -------------------------------------------------------------------------------- /docs/microservices/images/Saga pattern for the customer order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Saga pattern for the customer order.png -------------------------------------------------------------------------------- /docs/ui/angular/images/3.2-route-parameters-department-clicked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/3.2-route-parameters-department-clicked.png -------------------------------------------------------------------------------- /docs/oops/images/aggregation between a professor and department.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/oops/images/aggregation between a professor and department.png -------------------------------------------------------------------------------- /docs/ui/angular/images/1.5-spa-single-page-app-folder-structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/1.5-spa-single-page-app-folder-structure.png -------------------------------------------------------------------------------- /docs/ui/angular/images/3.1-route-parameters-department-list-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/3.1-route-parameters-department-list-home.png -------------------------------------------------------------------------------- /docs/ui/angular/images/7.4-optional-route-param-active-highlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/7.4-optional-route-param-active-highlight.png -------------------------------------------------------------------------------- /docs/ui/angular/images/difference-between-directives-components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/difference-between-directives-components.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/microservices/images/Different Layers in a Single Microservice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Different Layers in a Single Microservice.png -------------------------------------------------------------------------------- /docs/microservices/images/customer order example with microservices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/customer order example with microservices.png -------------------------------------------------------------------------------- /docs/spring/security/images/Figure 5. Multiple SecurityFilterChain .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/spring/security/images/Figure 5. Multiple SecurityFilterChain .png -------------------------------------------------------------------------------- /docs/ui/angular/images/5.2-optional-route-parameters-selected-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/ui/angular/images/5.2-optional-route-parameters-selected-list.png -------------------------------------------------------------------------------- /docs/microservices/images/2pc implementation for the customer order .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/2pc implementation for the customer order .png -------------------------------------------------------------------------------- /docs/microservices/images/Best Practices in Microservices Architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Best Practices in Microservices Architecture.png -------------------------------------------------------------------------------- /docs/microservices/images/Four different roles in OAuth 2.0 protocol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Four different roles in OAuth 2.0 protocol.png -------------------------------------------------------------------------------- /docs/microservices/images/Saga pattern for a compensation transaction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/Saga pattern for a compensation transaction.png -------------------------------------------------------------------------------- /docs/microservices/images/monolithic system using a local transactio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunilsoni/interview-docs/HEAD/docs/microservices/images/monolithic system using a local transactio.png -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /docs/algorithms/sorting.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Sorting 4 | parent: Data Structures 5 | resource: true 6 | desc: "Sorting interview questions and answers." 7 | categories: [Sorting] 8 | 9 | --- 10 | 11 | # Sorting 12 | {: .no_toc } 13 | 14 |
15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
22 | 23 | --- 24 | -------------------------------------------------------------------------------- /docs/ui/react/props.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: React Props 4 | parent: React 5 | grand_parent: UI Design 6 | --- 7 | 8 | 9 | # React Props 10 | 11 | {: .no_toc } 12 | 13 |
14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
21 | 22 | 23 | --- 24 | 25 | ## React Props 26 | 27 | 28 | --- 29 | 30 | ## React Props 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/ui/react/state.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: React State 4 | parent: React 5 | grand_parent: UI Design 6 | --- 7 | 8 | 9 | # React State 10 | 11 | {: .no_toc } 12 | 13 |
14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
21 | 22 | 23 | --- 24 | 25 | ## React State 26 | 27 | 28 | 29 | --- 30 | 31 | ## React State 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/ui/react/events.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: React Events 4 | parent: React 5 | grand_parent: UI Design 6 | --- 7 | 8 | 9 | # React Events 10 | 11 | {: .no_toc } 12 | 13 |
14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
21 | 22 | 23 | --- 24 | 25 | ## React Events 26 | 27 | 28 | 29 | --- 30 | 31 | ## React Events 32 | 33 | 34 | -------------------------------------------------------------------------------- /docs/ui/vue/vuejs.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Vuejs 4 | parent: UI Design 5 | has_children: true 6 | resource: true 7 | desc: "Vuejs interview questions and answers." 8 | categories: [Vuejs] 9 | --- 10 | 11 | # Vuejs 12 | {: .no_toc } 13 | 14 |
15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
22 | 23 | --- 24 | 25 | ## What is Vue.js 26 | 27 | -------------------------------------------------------------------------------- /docs/devops/devops.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: DevOps 4 | has_children: true 5 | nav_order: 2 6 | permalink: docs/devops 7 | resource: true 8 | desc: "DevOps interview questions and answers." 9 | categories: [DevOps] 10 | --- 11 | 12 | # DevOps 13 | {: .no_toc } 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | --- 25 | 26 | 27 | -------------------------------------------------------------------------------- /docs/misc/misc.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Misc 4 | has_children: true 5 | nav_order: 2 6 | permalink: docs/miscellaneous 7 | resource: true 8 | desc: "Miscellaneous interview questions and answers." 9 | categories: [Miscellaneous] 10 | --- 11 | 12 | # Miscellaneous 13 | {: .no_toc } 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | --- -------------------------------------------------------------------------------- /docs/ui/ui.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: UI Design 4 | has_children: true 5 | nav_order: 2 6 | resource: true 7 | desc: "UI Design interview questions and answers." 8 | categories: [UI Design] 9 | permalink: docs/ui 10 | --- 11 | 12 | # UI Design 13 | {: .no_toc } 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | --- 25 | 26 | 27 | --- 28 | 29 | ## UI Design -------------------------------------------------------------------------------- /docs/ui/angular/angular-lazy-loading.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Lazy Loading 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Lazy Loading interview questions and answers." 8 | categories: [Angular Lazy Loading] 9 | --- 10 | 11 | # Angular Lazy Loading 12 | {: .no_toc } 13 | 14 |
15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
22 | 23 | --- 24 | 25 | 26 | # Angular Lazy Loading 27 | 28 | 29 | 30 | For more information: 31 | 32 | [Data Binding in Angular 8](https://www.javatpoint.com/data-binding-in-angular-8) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _site/ 2 | .sass-cache/ 3 | .jekyll-cache/ 4 | .jekyll-metadata 5 | 6 | HELP.md 7 | target/ 8 | !.mvn/wrapper/maven-wrapper.jar 9 | !**/src/main/**/target/ 10 | !**/src/test/**/target/ 11 | 12 | ### STS ### 13 | .apt_generated 14 | .classpath 15 | .factorypath 16 | .project 17 | .settings 18 | .springBeans 19 | .sts4-cache 20 | 21 | ### IntelliJ IDEA ### 22 | .idea 23 | .idea/ 24 | *.iws 25 | *.iml 26 | *.ipr 27 | 28 | ### NetBeans ### 29 | /nbproject/private/ 30 | /nbbuild/ 31 | /dist/ 32 | /nbdist/ 33 | /.nb-gradle/ 34 | build/ 35 | !**/src/main/**/build/ 36 | !**/src/test/**/build/ 37 | 38 | 39 | 40 | ### VS Code ### 41 | .vscode/ 42 | .DS_Store 43 | /.DS_Store 44 | /.idea/ 45 | .idea/* -------------------------------------------------------------------------------- /sitemap.xml: -------------------------------------------------------------------------------- 1 | --- 2 | exclude: false 3 | --- 4 | 5 | 6 | 9 | {% for page in site.pages %}{% if page.exclude != true %} 10 | 11 | {{site.canonical_domain}}{{site.baseurl}}{{ page.url }} 12 | 0.8 13 | 14 | {% endif %}{% endfor %}{% for item in site.posts %}{% if page.exclude != true %} 15 | 16 | {{site.canonical_domain}}{{site.baseurl}}{{ item.url }} 17 | 0.8 18 | 19 | {% endif %}{% endfor %} 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Home 4 | nav_order: 1 5 | resource: true 6 | description: "Welcome to Interview Pages" 7 | permalink: / 8 | --- 9 | 10 | ## Welcome to Interview Pages 11 | 12 | --- 13 | 14 | {% for cat in site.category-list %} 15 | ### {{ cat }} 16 | 29 | {% endfor %} 30 | 31 | --- 32 | 33 | ## How to contribute 34 | 35 | Please feel free to raise issues if you can't get something to work, find a bug, or you have any ideas for improvements. 36 | 37 | --- 38 | 39 | 40 | 41 | 54 | -------------------------------------------------------------------------------- /docs/misc/behavioral-situational.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Behavioral & Situational 4 | parent: Misc 5 | resource: true 6 | desc: "Behavioral & Situational interview questions and answers." 7 | categories: [Behavioral & Situational] 8 | --- 9 | 10 | # Behavioral & Situational 11 | {: .no_toc } 12 | 13 |
14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
21 | 22 | --- 23 | 24 | 25 | 1. Tell me about yourself 26 | 2. How do you handle conflict? 27 | 3. How do you handle stress? 28 | 4. What are you passionate about? 29 | 5. Where do you see yourself in 5 years? 30 | 6. Do you have any questions for us? 31 | 7. Do you prefer to work alone or in groups? 32 | 8. Are you willing to relocate for this job? 33 | 9. If you were hired, how soon can you start? 34 | 10. Would you be willing to work nights and weekends? 35 | 11. Describe a situation where you disagreed with a supervisor. 36 | 12. Tell me about a time you had a conflict at work. 37 | 13. Tell me about a situation where you had to solve a difficult problem. 38 | 39 | 40 | ### what are you looking for in your next software development job ? 41 | 42 | In my next software development job, I am looking for opportunities to work on challenging and innovative projects, 43 | use the latest technologies, collaborate with a talented and diverse team, continuously learn and grow my skills, and make a positive impact in the organization and the world. 44 | 45 | 46 | 47 | 48 | 49 | 50 | ## For more information 51 | [200+ Job Interview Questions List](https://theinterviewguys.com/job-interview-questions/) 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /.idea/interview-docs.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/company/company.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Company 4 | has_children: true 5 | nav_order: 2 6 | permalink: docs/company 7 | resource: true 8 | desc: "company basic informations" 9 | categories: [company] 10 | --- 11 | 12 | # company 13 | {: .no_toc } 14 | 15 |
16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
23 | 24 | --- 25 | 26 | 27 | ## Banking 28 | 29 | ### Barclays 30 | 31 | 32 | Barclays is a global financial services company that offers a variety of products and services, including banking, credit cards, investments, and wealth management. If you have an interview with Barclays, it's likely that you are being considered for a role within one of these areas of the business. 33 | 34 | Here are some tips that may be helpful to you as you prepare for your interview: 35 | 36 | - **Research the company and the role you are applying for**: Familiarize yourself with Barclays' history, mission, and values, as well as the specific responsibilities and requirements of the role you are interviewing for. 37 | - **Practice your interview skills**: Make sure you are prepared to answer common interview questions, such as "Tell me about yourself," "Why do you want to work for Barclays?" and "What are your strengths and weaknesses?" 38 | - **Dress appropriately**: It's always important to dress professionally for an interview, especially at a financial services company like Barclays. 39 | - **Be prepared to ask questions**: Show your interest in the company and the role by coming prepared with a few well-thought-out questions for the interviewer. 40 | - **Practice your responses**: Consider practicing your responses to common interview questions with a friend or in front of a mirror to help you feel more confident on the day of the interview. 41 | 42 | I hope these tips are helpful as you prepare for your interview with Barclays. Good luck! 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /docs/ui/angular/angular-data-binding.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Data Binding 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Data Binding interview questions and answers." 8 | categories: [Angular Data Binding] 9 | --- 10 | 11 | # Angular Data Binding 12 | {: .no_toc } 13 | 14 |
15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
22 | 23 | --- 24 | 25 | 26 | 27 | Data binding is a core concept in Angular and allows to define communication between a component and the DOM, making it very easy to define interactive applications without worrying about pushing and pulling data. 28 | 29 | 30 | --- 31 | 32 | ## From the Component to the DOM 33 | ### 1. Interpolation 34 | {{ value }}: Adds the value of a property from the component 35 | 36 | ```html 37 |
  • Name: {{ user.name }}
  • 38 |
  • Address: {{ user.address }}
  • 39 | ``` 40 | 41 | ### 2. Property binding 42 | `[property] = "value"`: The value is passed from the component to the specified property or simple HTML attribute 43 | 44 | ```html 45 | 46 | ``` 47 | 48 | 49 | --- 50 | 51 | ## From the DOM to the Component 52 | 53 | ### 3. Event binding 54 | 55 | `(event) = "function"` : When a specific DOM event happens (eg.: click, change, keyup), call the specified method in the component 56 | 57 | ```html 58 | 59 | ``` 60 | 61 | ### 4. Two-way data binding 62 | `[(ngModel)] = "value"`: Two-way data binding allows to have the data flow both ways. For example, in the below code snippet, both the email DOM input and component email property are in sync 63 | 64 | ```html 65 | 66 | ``` 67 | 68 | 69 | 70 | --- 71 | 72 | ## For more information 73 | 74 | [Data Binding in Angular 8](https://www.javatpoint.com/data-binding-in-angular-8) -------------------------------------------------------------------------------- /docs/devops/maven.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Maven 4 | parent: DevOps 5 | resource: true 6 | desc: "Maven interview questions and answers." 7 | categories: [Maven] 8 | --- 9 | 10 | # Maven 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | Maven is a tool that is used for building and managing any Java based project. It is a powerful project management tool that is based on POM (Project Object Model). It simplifies the build process. 25 | 26 | --- 27 | 28 | ## pom.xml 29 | 30 | POM stands for Project Object Model, it is an xml file which contains the configuration information related to the project. Maven uses this file to build the project. We specify all the dependencies that are needed for a project, the plugins, goals etc. By using tag, we can specify whether we need to build the project into a JAR/WAR etc. 31 | 32 | --- 33 | 34 | ## Maven build life-cycle 35 | 36 | 37 | Maven build life-cycle is made up of phases 38 | - **validate**: validate the project is correct and all necessary information is available 39 | - **compile**: compile the source code of the project 40 | - **test**: test the compiled source code using a suitable unit testing framework. These tests should not require the code to be packaged or deployed 41 | - **package**: take the compiled code and package it in its distributable format, such as a JAR 42 | - **verify**: run any checks on results of integration tests to ensure quality criteria’s are met 43 | - **install**: install the package into the local repository, for using as a dependency in other projects locally 44 | - **deploy**: done in the build environment, copies the final package to the remote repository for sharing with other developers and projects 45 | 46 | Maven will first validate the project, then it will try to compile the sources, run the tests against the compiled code, package the binaries (e.g. jar), run integration tests against that package, verify the integration tests, install the verified package to the local repository and then deploy the installed package to a remote repository. 47 | mvn command can be used to execute these build life-cycle phases. If you run mvn verify, then it will execute all the phases in order, validate, compile, test, package before calling the verify . We only need to call the last build phase. 48 | mvn clean command is used to delete all the project jars that are built by Maven (/target directory of a project). Generally, this clean command is used with install/deploy phase, like mvn clean deploy to cleanly build and deploy artifacts into the shared repository. 49 | 50 | --- 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/ui/angular/sample.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Code Samples 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Code interview questions and answers." 8 | categories: [Samples] 9 | --- 10 | 11 | # Code Samples 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | 26 | ## Call backend rest apis call 27 | 28 | Angular 12 that makes a GET request to a Spring Boot RESTful API endpoint: 29 | 30 | ### Creates a new Angular project to call the backed API 31 | 32 | ```typescript 33 | import { Injectable } from '@angular/core'; 34 | import { HttpClient } from '@angular/common/http'; 35 | import { Observable } from 'rxjs'; 36 | 37 | @Injectable({ 38 | providedIn: 'root' 39 | }) 40 | export class MyService { 41 | 42 | private baseUrl = 'http://localhost:8080/api'; 43 | 44 | constructor(private http: HttpClient) { } 45 | 46 | getData(): Observable { 47 | return this.http.get(`${this.baseUrl}/data`); 48 | } 49 | } 50 | 51 | ``` 52 | 53 | This service is using the HttpClient module provided by Angular to make a GET request to the endpoint "http://localhost:8080/api/data". The http.get() method returns an observable, which can be subscribed to in a component to handle the response. 54 | 55 | Here's an example of how a component can use this service to make the GET request and handle the response: 56 | 57 | ```typescript 58 | import { Component, OnInit } from '@angular/core'; 59 | import { MyService } from './my.service'; 60 | 61 | @Component({ 62 | selector: 'app-my-component', 63 | template: ` 64 |
    65 | {{ data }} 66 |
    67 | ` 68 | }) 69 | export class MyComponent implements OnInit { 70 | 71 | data: any; 72 | 73 | constructor(private myService: MyService) { } 74 | 75 | ngOnInit() { 76 | this.myService.getData().subscribe( 77 | data => { 78 | this.data = data; 79 | }, 80 | error => { 81 | console.log(error); 82 | } 83 | ); 84 | } 85 | } 86 | 87 | ``` 88 | 89 | In this example, the component is injecting the service and using the ngOnInit() lifecycle hook to make the GET request when the component is initialized. The subscribe() method is used to handle the response of the GET request. If the request is successful, the response data is stored in the data property and displayed in the template using interpolation. In case of an error, it will log the error message. 90 | 91 | This is a simple example of how you can use Angular HttpClient module to make a GET request to a Spring Boot RESTful API endpoint. You can also use the http.post(), http.put(), and http.delete() methods to make POST, PUT, and DELETE requests respectively. 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /docs/graphql/graphql.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: GraphQL 3 | has_children: true 4 | nav_order: 2 5 | resource: true 6 | desc: "GraphQL interview questions and answers." 7 | categories: [GraphQL] 8 | --- 9 | 10 | --- 11 | 12 | # GraphQL 13 | {: .no_toc } 14 | 15 |
    16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
    23 | 24 | --- 25 | 26 | ## GraphQL 27 | 28 | GraphQL is a query language for APIs that was developed by Facebook. It allows clients to define the structure of the data that they require from an API, and the server will return exactly that data, and only that data. Here are some of the key components of GraphQL: 29 | 30 | ### Queries 31 | 32 | Queries are used by clients to request data from a GraphQL API. A query is a hierarchical set of fields and sub-fields that define the data that the client is requesting. Here is an example of a GraphQL query: 33 | 34 | ```scss 35 | query { 36 | user(id:123) { 37 | name 38 | email 39 | posts { 40 | title 41 | content 42 | } 43 | } 44 | } 45 | ``` 46 | 47 | This query is requesting the name and email of a user with an ID of 123, as well as the titles and content of all of that user's posts. 48 | 49 | 50 | ### Mutations 51 | 52 | Mutations are used by clients to modify data in a GraphQL API. A mutation is similar to a query, but it is used to make changes to the data, such as adding or deleting an object. Here is an example of a GraphQL mutation: 53 | 54 | ```scss 55 | mutation { 56 | addUser(name: "John Doe", email: "john@example.com") { 57 | id 58 | name 59 | email 60 | } 61 | } 62 | 63 | 64 | ``` 65 | This mutation is adding a new user to the API with a name of "John Doe" and an email of "john@example.com", and it is requesting the new user's ID, name, and email. 66 | 67 | ### Types 68 | 69 | Types are used by GraphQL to define the shape of the data that is available in the API. Types can be simple scalar types like strings and numbers, or they can be more complex object types that have their own fields and sub-fields. Here is an example of a GraphQL type: 70 | 71 | ```scss 72 | 73 | type User { 74 | id: ID! 75 | name: String! 76 | email: String! 77 | posts: [Post!]! 78 | } 79 | 80 | ``` 81 | 82 | This type defines a User object that has an ID, name, email, and a list of posts. The exclamation marks indicate that these fields are required. 83 | 84 | ### Resolvers 85 | Resolvers are functions that are used by a GraphQL server to fetch data from a data source and return it to the client. Each field in a query or mutation has its own resolver function that is responsible for fetching the data for that field. Here is an example of a resolver function: 86 | 87 | 88 | ```scss 89 | function getUserById(id) { 90 | // fetch user from database 91 | return { 92 | id: user.id, 93 | name: user.name, 94 | email: user.email, 95 | posts: getPostsByUserId(user.id), 96 | }; 97 | } 98 | 99 | 100 | ``` 101 | 102 | This resolver function takes an ID as an argument and fetches a user from a database, along with that user's posts. It then returns an object that matches the shape of the User type. 103 | 104 | 105 | -------------------------------------------------------------------------------- /docs/misc/git.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Git 4 | parent: Misc 5 | resource: true 6 | desc: "HTTP methods overview interview questions and answers." 7 | categories: [Git] 8 | --- 9 | 10 | # Git 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Git commands 25 | 26 | ### git add 27 | 28 | Moves changes from the working directory to the staging area. This gives you the opportunity to prepare a snapshot before committing it to the official history. 29 | 30 | 31 | 32 | 33 | ### git branch 34 | 35 | This command is your general-purpose branch administration tool. It lets you create isolated development environments within a single repository. 36 | 37 | 38 | ### git checkout 39 | 40 | In addition to checking out old commits and old file revisions, git checkout is also the means to navigate existing branches. Combined with the basic Git commands, it’s a way to work on a particular line of development. 41 | 42 | 43 | ### git clean 44 | 45 | Removes untracked files from the working directory. This is the logical counterpart to git reset, which (typically) only operates on tracked files. 46 | 47 | ### git clone 48 | Creates a copy of an existing Git repository. Cloning is the most common way for developers to obtain a working copy of a central repository. 49 | 50 | ### git commit 51 | 52 | Takes the staged snapshot and commits it to the project history. Combined with git add, this defines the basic workflow for all Git users. 53 | 54 | ### git commit --amend 55 | 56 | Passing the --amend flag to git commit lets you amend the most recent commit. This is very useful when you forget to stage a file or omit important information from the commit message. 57 | 58 | 59 | ### git config 60 | 61 | A convenient way to set configuration options for your Git installation. You’ll typically only need to use this immediately after installing Git on a new development machine. 62 | 63 | ### git fetch 64 | 65 | Fetching downloads a branch from another repository, along with all of its associated commits and files. But, it doesn't try to integrate anything into your local repository. This gives you a chance to inspect changes before merging them with your project. 66 | 67 | 68 | ### git init 69 | 70 | Initializes a new Git repository. If you want to place a project under revision control, this is the first command you need to learn. 71 | 72 | ### git log 73 | 74 | Lets you explore the previous revisions of a project. It provides several formatting options for displaying committed snapshots. 75 | 76 | 77 | ### git merge 78 | 79 | A powerful way to integrate changes from divergent branches. After forking the project history with git branch, git merge lets you put it back together again. 80 | 81 | ### git pull 82 | 83 | Pulling is the automated version of git fetch. It downloads a branch from a remote repository, then immediately merges it into the current branch. This is the Git equivalent of svn update. 84 | 85 | 86 | ### git 87 | 88 | 89 | ## More Details: 90 | 1. [Git commands](https://www.atlassian.com/git/glossary) 91 | 2. [Top 20 Git Commands With Examples](https://dzone.com/articles/top-20-git-commands-with-examples) 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /docs/ui/angular/angular-services.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Services 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Services interview questions and answers." 8 | categories: [Angular Services] 9 | --- 10 | 11 | # Angular Services 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | 26 | # Angular Services 27 | 28 | Angular services are singleton objects which get instantiated only once during the lifetime of an application. It contains method that maintain data throughout the life of an application, i.e. data does not get refreshed and is available all the time. The main objective of a service is to organize and share business logic, models, or data and functions with different components of an Angular application. 29 | 30 | **Benefits** 31 | 32 | An Angular service is a stateless object and provides some very useful functions. These functions can be invoked from any component of Angular, like Controllers, Directives, etc. This helps in dividing the web application into small, different logical units which can be reused. 33 | 34 | ```typescript 35 | import { Injectable } from '@angular/core'; 36 | import { Http } from '@angular/http'; 37 | 38 | @Injectable({ // The Injectable decorator is required for dependency injection to work 39 | // providedIn option registers the service with a specific NgModule 40 | providedIn: 'root', // This declares the service with the root app (AppModule) 41 | }) 42 | export class RepoService { 43 | constructor(private http: Http) { } 44 | 45 | fetchAll() { 46 | return this.http.get('https://api.github.com/repositories'); 47 | } 48 | } 49 | ``` 50 | 51 | The above service uses Http service as a dependency. 52 | 53 | ### Angular Service vs Interceptor 54 | 55 | * In Angular, a **service** is a `class` that is used to **encapsulate business logic, share data, and handle cross-component communication**. `Services` are typically used to handle tasks that are not directly related to the view, such as interacting with a backend API, handling browser storage, or logging events. `Services` are typically stateless and are injected into components or other services using Angular's dependency injection system. 56 | 57 | * An **interceptor**, on the other hand, is a `class` that is used to **intercept and modify HTTP requests and responses**. `Interceptors` are typically used to add headers, handle authentication, or handle errors. An `interceptor` is typically used to modify the request before it is sent and also handle the response after it is received. 58 | 59 | * In summary, `services` are a way to encapsulate and share business logic, data and cross-component communication, whereas `interceptors` are used to intercept and modify HTTP requests and responses, and are typically used to add headers, handle authentication, or handle errors. Both `services` and `interceptors` are used in Angular to separate concerns and make the code more maintainable. 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | For more information: 78 | 79 | [Introduction to services and dependency injection](https://angular.io/guide/architecture-services) -------------------------------------------------------------------------------- /docs/devops/kubernetes.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Kubernetes 4 | parent: DevOps 5 | resource: true 6 | desc: "Kubernetes interview questions and answers." 7 | categories: [Docker] 8 | --- 9 | 10 | # Kubernetes 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Kubernetes overview 25 | 26 | 27 | Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF). 28 | 29 | Kubernetes consists of several components that work together to provide a highly available and scalable platform for deploying and managing containerized applications. Here are some of the key components: 30 | 31 | `Master Node`: The master node is the control plane of the Kubernetes cluster. It manages the overall state of the cluster and coordinates the activities of the worker nodes. 32 | 33 | `Worker Nodes`: The worker nodes are the compute nodes of the Kubernetes cluster. They run the containerized applications and provide the compute resources needed to run those applications. 34 | 35 | `Kubernetes API Server`: The API server is the central component of the Kubernetes control plane. It exposes the Kubernetes API, which allows users and other components to interact with the cluster. 36 | 37 | `etcd`: etcd is a distributed key-value store that is used to store the state of the Kubernetes cluster. It is the source of truth for the entire cluster, and it is used by the Kubernetes API server to store and retrieve data. 38 | 39 | `Kubernetes Controllers`: Kubernetes controllers are responsible for monitoring the state of the cluster and making decisions about how to handle changes. They ensure that the desired state of the cluster is maintained at all times. 40 | 41 | `Kubernetes Scheduler`: The scheduler is responsible for assigning workloads to the worker nodes. It takes into account the resource requirements and constraints of the workloads and ensures that they are deployed in the most efficient way possible. 42 | 43 | 44 | Using Kubernetes with AWS is a common scenario. AWS provides several ways to run Kubernetes clusters on its platform, including Amazon Elastic Kubernetes Service (EKS), which is a fully managed service that makes it easy to run Kubernetes on AWS. Here are the general steps to use Kubernetes with AWS: 45 | 46 | Using Kubernetes with AWS is a common scenario. AWS provides several ways to run Kubernetes clusters on its platform, including Amazon Elastic Kubernetes Service (EKS), which is a fully managed service that makes it easy to run Kubernetes on AWS. Here are the general steps to use Kubernetes with AWS: 47 | 48 | `Create an Amazon EKS cluster`: Use the AWS Management Console, AWS CLI or SDKs to create an EKS cluster in your AWS account. 49 | 50 | `Configure kubectl`: Install and configure kubectl, the Kubernetes command-line tool, to interact with the EKS cluster. 51 | 52 | `Deploy containerized applications`: Use kubectl or other Kubernetes deployment tools to deploy containerized applications to the EKS cluster. 53 | 54 | `Scale and manage the cluster`: Use Kubernetes controllers and other Kubernetes management tools to scale and manage the EKS cluster. 55 | 56 | --- 57 | 58 | ## Kubernetes 59 | 60 | -------------------------------------------------------------------------------- /docs/aws/ec2.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: EC2 4 | parent: AWS 5 | resource: true 6 | desc: "AWS - Elastic Compute Cloud (EC2) interview questions and answers." 7 | categories: [AWS - Elastic Compute Cloud (EC2)] 8 | 9 | --- 10 | 11 | # AWS - Elastic Compute Cloud (EC2) 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | 26 | ## Elastic Compute Cloud (EC2) 27 | 28 | Elastic Compute Cloud (EC2) is a web service provided by Amazon Web Services (AWS) that allows users to rent virtual servers, known as instances, in the cloud. With EC2, users can easily scale computing resources up or down according to their needs, paying only for the resources they consume, and without the need to invest in physical hardware. 29 | 30 | Key features of Amazon EC2: 31 | 32 | 1. **Virtual Instances**: EC2 provides a variety of pre-configured virtual machine instances, each with different combinations of CPU, memory, storage, and network capacity. Users can choose from various instance types to match their specific workload requirements. 33 | 34 | 2. **Flexible Pricing**: EC2 offers different pricing models, including On-Demand, Reserved Instances, and Spot Instances. On-Demand instances allow users to pay for compute capacity by the hour or second without any long-term commitments. Reserved Instances offer significant cost savings for users who commit to a one- or three-year term. Spot Instances allow users to bid on unused EC2 capacity, potentially obtaining instances at a much lower cost. 35 | 36 | 3. **Scalability**: EC2 allows users to scale the number of instances up or down based on demand. This enables handling sudden traffic spikes or adjusting resources to accommodate varying workloads. 37 | 38 | 4. **Security**: EC2 provides various security features, including Virtual Private Cloud (VPC) integration, security groups, network access control lists (ACLs), and the ability to use AWS Identity and Access Management (IAM) to control access to resources. 39 | 40 | 5. **AMI (Amazon Machine Image)**: Users can create custom AMIs or use pre-built ones, which are templates containing the necessary software configurations to launch instances. 41 | 42 | 6. **Elastic Block Store (EBS)**: EC2 instances can be associated with EBS volumes, which provide persistent block-level storage. EBS volumes can be easily attached, detached, and backed up as needed. 43 | 44 | 7. **Load Balancing**: EC2 instances can be combined with Elastic Load Balancing (ELB) to distribute incoming traffic across multiple instances, ensuring high availability and fault tolerance. 45 | 46 | 8. **Auto Scaling**: EC2 can be integrated with Auto Scaling, which automatically adjusts the number of instances based on predefined conditions, ensuring optimal performance and cost efficiency. 47 | 48 | 9. **Integration with Other AWS Services**: EC2 can be seamlessly integrated with various other AWS services, such as Amazon RDS, Amazon S3, AWS Lambda, and more, to create comprehensive and sophisticated cloud solutions. 49 | 50 | EC2 is widely used by businesses of all sizes, developers, and individuals who require scalable and flexible compute resources in the cloud. It enables users to run a wide range of applications, from simple web servers to complex enterprise applications, without the burden of managing physical infrastructure. 51 | 52 | 53 | -------------------------------------------------------------------------------- /docs/ui/angular/angular-cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: CLI 4 | parent: Angular 5 | resource: true 6 | nav_order: 6 7 | grand_parent: UI Design 8 | desc: "Angular CLI (Command Line Interface) interview questions and answers." 9 | categories: [Angular Pipes] 10 | --- 11 | 12 | # Angular CLI (Command Line Interface) 13 | {: .no_toc } 14 | 15 |
    16 | 17 | Table of contents 18 | 19 | {: .text-delta } 20 | 1. TOC 21 | {:toc} 22 |
    23 | 24 | --- 25 | 26 | Angular is a JavaScript framework for building web applications and Angular CLI (Command Line Interface) is a tool that helps to create, manage, and test Angular projects. Here are some commonly used Angular CLI commands: 27 | 28 | ### `ng new [project-name]` 29 | 30 | Creates a new Angular project with the given name. 31 | 32 | ```typescript 33 | ng new my-project 34 | ``` 35 | 36 | ### `ng serve` 37 | 38 | Runs the project locally in development mode and starts a development server. It also watches for file changes and automatically rebuilds the application. 39 | 40 | ```typescript 41 | ng serve 42 | ``` 43 | 44 | ### `ng generate [schematic] [name]` 45 | 46 | Generates new files and updates existing files based on a schematic. The schematic can be a component, service, module, etc. 47 | 48 | ```typescript 49 | ng generate component my-component 50 | ``` 51 | 52 | ### `ng build` 53 | 54 | Builds the project for production and creates a distribution version in the dist folder. It also minifies and optimizes the code for better performance. 55 | 56 | ```typescript 57 | ng build --prod 58 | ``` 59 | 60 | ### `ng test` 61 | 62 | Runs unit tests for the project using the Karma test runner. 63 | 64 | 65 | ```typescript 66 | ng test 67 | ``` 68 | 69 | ### `ng lint` 70 | 71 | Lints the project's code using the configured linter. It checks for code style and potential errors. 72 | 73 | 74 | 75 | ```typescript 76 | ng lint 77 | ``` 78 | 79 | ### `ng e2e` 80 | 81 | Runs end-to-end (E2E) tests for the project using the Protractor test framework. 82 | 83 | 84 | ```typescript 85 | ng e2e 86 | ``` 87 | 88 | ### `ng update` 89 | 90 | Updates the project's dependencies and configuration to the latest version of Angular. 91 | 92 | 93 | ```typescript 94 | ng update @angular/cli 95 | ``` 96 | 97 | ### `ng xi18n` 98 | 99 | Extracts i18n messages from the project's code for localization. 100 | 101 | 102 | ```typescript 103 | ng xi18n --output-path src/locale 104 | ``` 105 | 106 | ### `ng add [package]` 107 | 108 | Add new capabilities to your project with additional libraries or packages. 109 | 110 | 111 | ```typescript 112 | ng add @ng-bootstrap/schematics 113 | ``` 114 | 115 | ### `ng deploy` 116 | 117 | Deploys the application to a specified platform. 118 | 119 | 120 | ```typescript 121 | ng deploy --project my-project 122 | ``` 123 | 124 | ### `ng doc [keyword]` 125 | 126 | Opens the official Angular documentation in the browser and searches for the specified keyword. 127 | 128 | ```typescript 129 | ng doc component 130 | ``` 131 | ### `ng eject` 132 | 133 | Ejects the project from the Angular CLI and gives you full control over the build and configuration. 134 | 135 | ```typescript 136 | ng eject 137 | ``` 138 | 139 | ### ` ng help` 140 | 141 | Displays a list of available commands and their descriptions. 142 | 143 | ```typescript 144 | ng help 145 | ``` 146 | ### `ng version` 147 | 148 | Shows the version of the installed Angular CLI and the version of the locally installed packages. 149 | 150 | ```typescript 151 | ng version 152 | ``` 153 | 154 | 155 | -------------------------------------------------------------------------------- /docs/java/java17.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Java 17 4 | parent: Java 5 | resource: true 6 | desc: "Java 17 interview questions and answers." 7 | categories: [Java 17] 8 | --- 9 | 10 | # Java 17 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | 25 | ## Java 17 New features 26 | 27 | Java 17 is a version of the Java programming language that was released in September 2021. It includes a number of new features and improvements, including: 28 | 29 | - Sealed Classes: Sealed classes allow developers to explicitly specify which classes can extend or implement a given class, and provide a way to control which methods can be called on instances of those classes. 30 | - Records: Records are a new kind of type in Java that provide a concise way to define a simple data holder class, similar to a struct in C or a data class in Kotlin. 31 | - Pattern Matching for instanceof: The instanceof operator now supports pattern matching, which allows developers to write more concise and readable code when working with complex data structures. 32 | - Text Blocks: Text blocks are a new kind of string literal that can span multiple lines of code and preserve line breaks and white space. 33 | - Foreign-Memory Access API: The Foreign-Memory Access API is a new set of low-level APIs that allow Java programs to directly access and manipulate memory outside the Java heap. 34 | - Hidden Classes: Hidden classes are a new kind of class that can be created at runtime, but are not visible to the class loader. They are intended to be used as implementation details of other classes, and can help improve the performance and security of Java programs. 35 | - Improved Socket API: The Socket API has been updated to support new features, including socket options, IPv6 support, and support for datagram sockets. 36 | - Enhanced Deprecation: Deprecated APIs can now be marked with a severity level, which allows developers to indicate the level of impact that their removal will have on users of the API. 37 | - Reimplementation of the Legacy Datagram and MulticastSocket APIs: The legacy Datagram and MulticastSocket APIs have been re-implemented to improve their performance and reliability. 38 | - Improved Performance of java.util.Map: The performance of the java.util.Map interface has been improved, with the addition of new methods and optimizations to existing methods. 39 | - Improved Performance of java.util.stream: The performance of the java.util.stream API has been improved, with the addition of new methods and optimizations to existing methods. 40 | - Enhanced Support for Unicode: Java 17 includes improved support for Unicode, including the addition of new characters and support for new scripts. 41 | - Enhanced Support for TLS 1.3: Java 17 includes improved support for the TLS 1.3 security protocol, including the addition of new APIs and improved performance. 42 | - Enhanced Support for JFR Events: Java Flight Recorder (JFR) is a tool for collecting and analyzing data about the performance and behavior of a Java application. Java 17 includes enhanced support for JFR events, including the ability to trigger events based on custom criteria. 43 | - Enhanced Support for Native Image Generation: The Native Image Generation tool allows developers to create a native executable image from a Java application, which can improve the performance of the application. Java 17 includes enhanced support for native image generation, including the ability to generate images for ARM64 architectures. 44 | - Enhanced Support for Application Class-Data Sharing: Application Class-Data Sharing (AppCDS) is a feature that allows multiple Java applications to share common class data, which can improve the start-up time and memory usage of those applications. Java 17 includes enhanced support for AppCDS, including the ability to create and use shared class data from the command line. 45 | - Enhanced Support for JVM Constants API: The JVM Constants API is a set of APIs that allow Java programs to access and manipulate constants at 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/ui/angular/angular-pipes.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Pipes 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Pipes interview questions and answers." 8 | categories: [Angular Pipes] 9 | --- 10 | 11 | # Angular Pipes 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | Angular Pipes are used to transform data on a template, without writing a boilerplate code in a component. 26 | 27 | A pipe takes in data as input and transforms it to the desired output. It is like a filter in Angular 1 (AngularJS). 28 | 29 | Generally, If we need to transform data, we write the code in the component, For example, we want to transform today’s date into a format like `'16 Apr 2018'` or `'16-04-2018'` 30 | ,We need to write separate code in the component. 31 | 32 | So instead of writing separate boilerplate code, we can use the built-in pipe called `DatePipe` which will take input and transform it into the desired date format. 33 | 34 | --- 35 | 36 | ## Syntax to use Pipes in Angular Application 37 | 38 | 39 | 40 | 41 | A pipe takes in data as input and transforms it to a desired output. For example, let us take a pipe to transform a component birthday property into a human-friendly date using date pipe. 42 | 43 | 44 | --- 45 | 46 | ## Angular Pipes 47 | 48 | https://github.com/sunilsoni/interview-notes/blob/main/angular/angular-pipes.md 49 | 50 | --- 51 | 52 | ## what is pure vs impure pipes angular? 53 | 54 | In Angular, pipes are a way to transform data in a template. Pipes take an input value and return a transformed output value. 55 | 56 | There are two types of pipes in Angular: **pure** and **impure**. 57 | 58 | A pure pipe is a pipe that only runs when one of the following is true: 59 | 60 | * The input value to the pipe is different from the previous input value. 61 | 62 | * The pipe is marked as pure and the component that contains the pipe is being destroyed. 63 | 64 | 65 | * A `pure pipe` is efficient because it only runs when it needs to, which can improve the performance of your application. 66 | 67 | * An `impure pipe` is a pipe that runs on every change detection cycle, regardless of whether the input value has changed. 68 | 69 | * A pure pipe is the default in Angular, and the pipe is marked as pure by default. You can mark a pipe as impure by setting the `pure` property of the `@Pipe` decorator to `false`. 70 | 71 | **An example of a pure pipe:** 72 | 73 | ```log 74 | import { Pipe, PipeTransform } from '@angular/core'; 75 | 76 | @Pipe({ 77 | name: 'filter', 78 | pure: true 79 | }) 80 | export class FilterPipe implements PipeTransform { 81 | transform(value: any, filterString: string, propName: string): any { 82 | if (value.length === 0 || filterString === '') { 83 | return value; 84 | } 85 | const resultArray = []; 86 | for (const item of value) { 87 | if (item[propName] === filterString) { 88 | resultArray.push(item); 89 | } 90 | } 91 | return resultArray; 92 | } 93 | } 94 | 95 | ``` 96 | * In this example, the `FilterPipe` is a pure pipe, it only runs when the input value or filterString changes. 97 | 98 | **An example of an impure pipe:** 99 | 100 | ```log 101 | import { Pipe, PipeTransform } from '@angular/core'; 102 | 103 | @Pipe({ 104 | name: 'random', 105 | pure: false 106 | }) 107 | export class RandomPipe implements PipeTransform { 108 | transform(value: any): any { 109 | return value[Math.floor(Math.random() * value.length)]; 110 | } 111 | } 112 | 113 | ``` 114 | * In this example, the `RandomPipe` is an impure pipe, it runs on every change detection cycle, regardless of whether the input value has changed. 115 | 116 | In summary, pure pipes are efficient because they only run when they need to, while impure pipes run on every change detection cycle. By default, pipes are pure, but you can mark a pipe as impure by setting the pure property of the `@Pipe` decorator to `false`. 117 | 118 | --- -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: Interview Docs 2 | tagline : Interview questions and answers 3 | description: Interview questions and answers notes or docs 4 | # baseurl: "/interview-docs" # the subpath of your site, e.g. /blog 5 | baseurl: "" 6 | url: https://interview-docs.com # the base hostname & protocol for your site, e.g. http://example.com 7 | author: 8 | name: Sunil Soni 9 | email: docs.interview@gmail.com 10 | github: sunilsoni 11 | 12 | production_url: https://interview-docs.com 13 | 14 | # Set a path/url to a logo that will be displayed instead of the title 15 | #logo: "/utils/job-logo.jpeg" 16 | 17 | remote_theme: pmarsceill/just-the-docs 18 | # Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define 19 | color_scheme: nil 20 | 21 | theme: jekyll-theme-minimal 22 | 23 | # Split pages into sections that can be searched individually 24 | # Supports 1 - 6, default: 2 25 | search.heading_level: 6 26 | 27 | # Sort order for navigation links 28 | # nav_sort: case_insensitive # default, equivalent to nil 29 | nav_sort: case_insensitive # Capital letters sorted before lowercase 30 | # Enable or disable the site search 31 | # Supports true (default) or false 32 | search_enabled: true 33 | search: 34 | # Split pages into sections that can be searched individually 35 | # Supports 1 - 6, default: 2 36 | heading_level: 6 37 | # Maximum amount of previews per search result 38 | # Default: 3 39 | previews: 10 40 | # Maximum amount of words to display before a matched word in the preview 41 | # Default: 5 42 | preview_words_before: 5 43 | # Maximum amount of words to display after a matched word in the preview 44 | # Default: 10 45 | preview_words_after: 20 46 | # Set the search token separator 47 | # Default: /[\s\-/]+/ 48 | # Example: enable support for hyphenated search words 49 | tokenizer_separator: /[\s/]+/ 50 | # Display the relative url in search results 51 | # Supports true (default) or false 52 | rel_url: true 53 | # Enable or disable the search button that appears in the bottom right corner of every page 54 | # Supports true or false (default) 55 | button: true 56 | 57 | # Enable or disable heading anchors 58 | heading_anchors: true 59 | 60 | # Aux links for the upper right navigation 61 | # aux_links: 62 | # "Interview questions and answers": 63 | # - "//github.com/sunilsoni/interview-docs" 64 | 65 | # Makes Aux links open in a new tab. Default is false 66 | aux_links_new_tab: true 67 | 68 | # Color scheme supports "light" (default) and "dark" 69 | color_scheme: light 70 | 71 | # Back to top link 72 | back_to_top: true 73 | back_to_top_text: "Back to top" 74 | 75 | footer_content: "Copyright © 2022-2023 Interview Docs Email: docs.interview@gmail.com" 76 | 77 | # Footer last edited timestamp 78 | last_edit_timestamp: true # show or hide edit time - page must have `last_modified_date` defined in the frontmatter 79 | last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html 80 | 81 | 82 | # Google Analytics Tracking (optional) 83 | # e.g, UA-1234567-89 84 | ga_tracking: UA-2709176-22 85 | ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings (true/nil by default) 86 | 87 | plugins: 88 | - jekyll-seo-tag 89 | 90 | 91 | category-list: [System Design, GraphQL,Array,Data Structures,Dynamic Programming,Intergers,Linked List,Queue,Sorting,String,Angular,Angular Component,Angular Data Binding,Angular Directive,Angular Lazy Loading,Angular Lifecycle Hooks,Angular Pipes,Angular Routing and Navigation,Angular Services,Versioning and releases,RxJS,Amazon Web Services (AWS),AWS CloudFormation,AWS DynamoDB,AWS - Elastic Compute Cloud (EC2),AWS Lambda,Simple Storage Service (S3),Database,Hibernate,MongoDB,Behavioral Design Pattern,Creational Design Pattern,Design Patterns,Structural Design Pattern,DevOps,Docker,Linux,Maven,Collection Framework,Java,Java 8,Java Basics,Multi threading,Kafka,API Gateway,Microservices,Security in Microservices,Managing transactions,Behavioral & Situational,Cucumber,Good Practices,HTTP methods overview,Miscellaneous,Common Java Vulnerabilities,Object-oriented programming(OOPS),React,Spring,Spring AOP,Spring Batch,Spring Boot,Spring MVC,Swagger,Spring Data JPA,Spring Cloud,Spring Security, SQL Queries,Microservices Design Patterns,Git,Production,Samples,VueJs,UI Design] -------------------------------------------------------------------------------- /docs/ system-design /system-design.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: System Design 3 | has_children: true 4 | nav_order: 2 5 | resource: true 6 | desc: "System Design interview questions and answers with focus on real-world problems and solutions." 7 | categories: [System Design] 8 | --- 9 | 10 | # System Design 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Introduction 25 | 26 | System design is a significant part of the software engineering interview process, particularly for mid-level and senior roles. Mastering the art of system design requires a solid understanding of the fundamental principles, a keen eye for identifying problems, and a systematic approach to creating solutions. This page serves as a comprehensive resource for system design interview preparation. 27 | 28 | --- 29 | 30 | ## [System Design Interview Tips](https://github.com/checkcheckzz/system-design-interview) 31 | 32 | An essential guide providing tips for system design interviews. It covers aspects like scalability, performance, and system components. 33 | 34 | --- 35 | 36 | ## [System Design Interview Questions](https://github.com/sid24rane/System-Design-Interview-Questions) 37 | 38 | A collection of common system design questions that are often asked in interviews. 39 | 40 | --- 41 | 42 | ## [The System Design Primer](https://github.com/donnemartin/system-design-primer) 43 | 44 | A resource offering a wide range of information on system design principles, including scaling, databases, and system components. 45 | 46 | --- 47 | 48 | ## [Preparation for Lateral Hiring](https://medium.com/@varungarg6781/preparation-for-lateral-hiring-1d19aac437ef) 49 | 50 | Insights into preparing for system design interviews, especially for lateral hiring positions. 51 | 52 | --- 53 | 54 | ## [System Design Cheatsheet](https://gist.github.com/vasanthk/485d1c25737e8e72759f) 55 | 56 | A quick reference guide for key system design concepts and terminologies. 57 | 58 | --- 59 | 60 | ## Real-World System Design Challenges 61 | 62 | ### Facebook 63 | 64 | - [Designing Facebook's News Feed](https://leetcode.com/discuss/interview-question/719253/Design-Facebook-%3A-System-Design-Interview) 65 | - [Web Crawler System Design](https://leetcode.com/discuss/interview-question/124657/Facebook-or-System-Design-or-A-web-crawler-that-will-crawl-Wikipedia) 66 | 67 | ### Google 68 | 69 | - [Designing a Video Sharing Platform like YouTube](https://leetcode.com/discuss/interview-question/system-design/733520/Design-YouTube-Very-detailed-design-with-diagrams) 70 | - [Designing a Translation Service like Google Translate](https://leetcode.com/discuss/interview-question/system-design/318811/Google-or-System-design-or-Design-a-translation-service-like-Google-Translate) 71 | 72 | ### Amazon 73 | 74 | - [Unique Address Capture System](https://leetcode.com/discuss/interview-question/341980/Amazon-or-System-Design-or-System-to-capture-unique-addresses-in-the-entire-world) 75 | - [Amazon's "Customers who bought this item also bought" Recommendation System](https://leetcode.com/discuss/interview-question/system-design/124557/Amazon's-"Customers-who-bought-this-item-also-bought"-recommendation-system) 76 | 77 | ### Uber 78 | 79 | - [Designing a Location Sharing Android Application](https://leetcode.com/discuss/interview-question/124673/Design-a-Location-Sharing-Android-Application) 80 | - [Designing Uber Backend](https://leetcode.com/discuss/interview-question/124542/Design-Uber-Backend) 81 | 82 | ### Microsoft 83 | 84 | - [Designing a Distributed Counter](https://leetcode.com/discuss/interview-question/system-design/685310/Microsoft-virtual-or-Design-distributed-counter) 85 | - [Designing a System to Store Millions of Subscribers' List](https://leetcode.com/discuss/interview-question/system-design/680047/How-will-you-store-millions-of-subscribers-list-(assume-it-as-email-id)) 86 | 87 | --- 88 | 89 | ## Additional Resources 90 | 91 | - [Distributed Systems Introduction](https://leetcode.com/discuss/general-discussion/1105898/System-Design%3A-Introduction-to-Distributed-Systems-or-Designing-a-highly-available-system) 92 | - [Machine Learning System Design](https://leetcode.com/discuss/interview-question/system-design/566057/Machine-Learning-System-Design-%3A-A-framework-for-the-interview-day) 93 | - [System Design for Mobile App Developers](https://leetcode.com/discuss/interview-question/system-design/691010/System-Design-for-Mobile-App-Developers) 94 | 95 | --- 96 | 97 | -------------------------------------------------------------------------------- /docs/spring/spring-cloud.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Spring Cloud 4 | parent: Spring 5 | resource: true 6 | desc: "Spring Cloud interview questions and answers." 7 | categories: [Spring Cloud] 8 | --- 9 | 10 | # Spring Cloud 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Introducing Spring Cloud 25 | 26 | 27 | ## Spring Cloud 28 | 29 | Spring team has integrated number of battle-tested open source projects from companies like Pivotal, Netflix into a Spring project known as Spring Cloud. Spring Cloud provides libraries & tools to quickly build some of the common design patterns of distributed system, including the following: 30 | 31 | **Spring Cloud Patterns and Libraries** 32 | 33 | 34 | | Category | Pattern Name | Spring Cloud Library | 35 | | ---------------------- | ------------------------------------------------ | --------------------------------------------- | 36 | | Development Patterns | Distributed/versioned configuration management | Spring Cloud Config Server | 37 | | | Core Microservices Patterns | Spring Boot | 38 | | | Asynchronous/Distributed Messaging | Spring Cloud Stream (AMQP and Kafka) | 39 | | | Inter-Service Communication | RestTemplate and Spring Cloud Feign | 40 | | Routing Patterns | Service Registration & Discovery | Spring Cloud Netflix Eureka & Consul | 41 | | | Service Routing/ API Gateway Pattern | Spring Cloud Netflix Zuul | 42 | | Resiliency Patterns | Client side load balancing | Spring Cloud Netflix Ribbon | 43 | | | Circuit Breaker & Fallback Pattern | Spring Cloud Netflix Hystrix | 44 | | | Bulkhead pattern | Spring Cloud / Spring Cloud Netflix Hystrix | 45 | | Logging Patterns | Log Correlation | Spring Cloud Sleuth | 46 | | | Microservice Tracing | Spring Cloud Sleuth/Zipkin | 47 | | Security Patterns | Authorization and Authentication | Spring Cloud Security OAuth2 | 48 | | | Credentials Management | Spring Cloud Security OAuth2/ JWT | 49 | | | Distributed Sessions | Spring Cloud OAuth2 and Redis | 50 | 51 | Spring Cloud makes it really easy to develop, deploy and operate JVM applications for the Cloud. 52 | 53 | Different release trains in Spring Cloud at the time of writing this handbook are (newest to oldest) - Finchley, Edgware, Dalston and Camden. Spring Cloud is always used in conjunction with Spring Boot. 54 | 55 | A bare minimum `build.gradle` for any Spring Cloud project will look like: 56 | 57 | **build.gradle** 58 | 59 | ```properties 60 | buildscript { 61 | ext { 62 | springBootVersion = '1.5.12.RELEASE' 63 | } 64 | repositories { 65 | mavenCentral() 66 | } 67 | dependencies { 68 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 69 | } 70 | } 71 | apply plugin: 'java' 72 | apply plugin: 'spring-boot' 73 | dependencyManagement { 74 | imports { 75 | mavenBom ':spring-cloud-dependencies:Edgware.SR3' 76 | } 77 | } 78 | dependencies { 79 | compile ':spring-cloud-starter-config' 80 | compile ':spring-cloud-starter-eureka' 81 | } 82 | 83 | ``` 84 | 85 | - Edgware.SR3 is the spring-cloud train version. 86 | - Spring cloud dependencies (eureka client and config client) 87 | 88 | And a minimal version of `spring-cloud` Application: 89 | 90 | ```java 91 | @SpringBootApplication 92 | @EnableDiscoveryClient 93 | public class Application { 94 | public static void main(String[] args) { 95 | SpringApplication.run(Application.class, args); 96 | } 97 | } 98 | 99 | ``` 100 | 101 | - Enables spring-boot in your application. 102 | - Enables discovery-client: a spring-cloud feature in your microservice that helps you discover other services in a given environment. 103 | 104 | 105 | 106 | --- 107 | 108 | ## Reference Links 109 | - [Spring Cloud](http://projects.spring.io/spring-cloud/) -------------------------------------------------------------------------------- /.idea/sonarlint/issuestore/index.pb: -------------------------------------------------------------------------------- 1 | 2 | : 3 | 4 | .gitignore,a/5/a5cc2925ca8258af241be7e5b0381edf30266302 5 | 9 6 | README.md,8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d 7 | C 8 | docs/react/React.md,a/3/a391bfddc53eefbf96b7c66e8410e47fdc5a3059 9 | E 10 | docs/spring/Spring.md,d/6/d6eb03167597809a63b652ef7502f9b21181531c 11 | E 12 | docs/devops/DevOps.md,0/6/06575c0cdc20da6ff233ca3391d4d8f87dba6761 13 | I 14 | docs/database/Database.md,a/5/a5d5822dcc01f21e2697a7bf395d7ddefa155a0b 15 | H 16 | _sass/custom/custom.scss,7/a/7a67b28b5645f838c736d6ae21b2a80b3f352b11 17 | E 18 | _layouts/default.html,8/8/88dc137ae43bf7a2fa27381f48221b3eb9908aac 19 | J 20 | docs/algorithms/sorting.md,2/c/2cd6b61ecb52be5dd51c8a6814f36db8cdd952c3 21 | G 22 | docs/angular/Angular.md,9/4/9443ccbe6ac6bc1d29a6d352a0ccc19bb9252814 23 | R 24 | "docs/angular/angular-components.md,8/8/88a9c5d705aba299df45f3a2cf599211e02b58ee 25 | T 26 | $docs/angular/angular-data-binding.md,0/c/0c458d76440cd68d9c040333cf0e7895f1c5f2e4 27 | Q 28 | !docs/angular/angular-directive.md,1/5/1555659765c0ecf373a4c692cae64595db6c683c 29 | T 30 | $docs/angular/angular-lazy-loading.md,2/a/2ab17f557b882d27382614562fbfbf59406a1f70 31 | W 32 | 'docs/angular/angular-lifecycle-hooks.md,3/9/395b2bd4db7d3eb5cd20cdff70fe3a679ee8074e 33 | M 34 | docs/angular/angular-pipes.md,b/a/ba9a5fd08205659c9d4821a5f4c02def2b7da245 35 | O 36 | docs/angular/angular-routing.md,4/6/468cd43cea64592a1b5c66f64521b4de5b3468ce 37 | P 38 | docs/angular/angular-services.md,e/d/edb16c2cc417eb13440905b5e152b15cb44e3e6c 39 | R 40 | "docs/angular/Angular-versioning.md,4/2/42ca1fa527ac4a0d169428651e2689247a1f3219 41 | D 42 | docs/angular/rxjs.md,7/e/7ed4c3538e0c80a89345e0c84f36b78c0f2da0fd 43 | ? 44 | docs/aws/aws.md,e/c/ecd2f7d76ed36c5f12aa55096970332f97c36075 45 | K 46 | docs/aws/cloud-formation.md,5/7/57de355925bee8bbccc6cbe5c34ae79821dc806d 47 | ? 48 | docs/aws/ec2.md,c/2/c22f3faa37020d9f36bce7dc253ede01272129f9 49 | B 50 | docs/aws/lambda.md,8/1/81a9caf47ce4671d11daaa542ebf3f20e47f7e4a 51 | > 52 | docs/aws/s3.md,b/3/b3c5f61fa1b22553f9769f3a9614ea13106ef1de 53 | a 54 | 1docs/design-patterns/behavioral-design-pattern.md,8/f/8fdd65f611c3404fa98a2726c9cd0098ad557a3a 55 | a 56 | 1docs/design-patterns/creational-design-pattern.md,8/2/8241dedcb63156a61d01eb553805357278d7e444 57 | V 58 | &docs/design-patterns/design-pattern.md,b/1/b18f43ac389f0256bc363a87c55c6b73c3ecec84 59 | a 60 | 1docs/design-patterns/structural-design-pattern.md,d/1/d17e47a7804fb24d310438debb19a6d1ae38e372 61 | E 62 | docs/devops/devops.md,9/c/9cbd69e6676612f6e3df53eef4762658963b43a4 63 | D 64 | docs/devops/linux.md,3/3/33753fc113e7095214f3c50f134db111bcc6ec9d 65 | D 66 | docs/devops/maven.md,7/1/71d021faa6c1d41c17afd2cec67983aed82dcdf0 67 | Q 68 | !docs/microservices/api-gateway.md,e/3/e38d674e08e29afca17ec80dcbc44d4e82be67c3 69 | N 70 | docs/microservices/security.md,7/5/75e53dd9dc96f0f64c0bed498e49dadac4cbcb70 71 | \ 72 | ,docs/miscellaneous/behavioral-situational.md,6/6/664d196ad7f865783fabc974660627ddebd8f20d 73 | N 74 | docs/miscellaneous/cucumber.md,e/8/e840ce8d2dc974328fa821b030f713323ef2c824 75 | T 76 | $docs/miscellaneous/good-practices.md,c/6/c6da723436b1829ce20b45982c978bbe0f7f6a3c 77 | K 78 | docs/miscellaneous/owasp.md,9/8/987469032e7cd4aeaa999de41e93e35b07501f1e 79 | K 80 | docs/spring/swagger-docs.md,d/6/d64399927feabbd851eed1ebf5e86fc1214ec665 81 | E 82 | docs/devops/docker.md,3/5/35e217f1df9e019f153f02996d68ce9b9079c46e 83 | D 84 | docs/aws/dynamodb.md,c/5/c5d25b75538bae41f8b23c1da8030b92d9798c8c 85 | J 86 | docs/spring/spring-boot.md,6/7/67bc5efde8f14d2aa13c05ab9a0b63d5d5497a8a 87 | I 88 | docs/spring/Spring-aop.md,5/d/5d8fa5d628fa64a643b0a02b55fef37ce1c79759 89 | N 90 | docs/spring/spring-data-jpa.md,2/c/2c70240fee40d1864675dc4fb06b22ac8d74056a 91 | C 92 | docs/react/react.md,d/2/d275d4faab36ca1e695eebfe5d1fd724a1200cd6 93 | A 94 | docs/java/Java.md,d/e/de418fc77c20469d2a13acceba21fc24fe95896c 95 | S 96 | #docs/microservices/microservices.md,a/b/ab0d77c7ebc3ca623999f7b3cbb108b8b84acf7f 97 | c 98 | 3docs/microservices/microservices-design-patterns.md,8/3/836f10287c7415b19ff10d9241121a1f9dc399dd 99 | J 100 | docs/miscellaneous/misc.md,4/8/48bdb2278012630f697cfbe6328733706290d206 101 | J 102 | docs/miscellaneous/http.md,b/f/bf9a98df73080c8a7d299bfa51af20ce953cb743 103 | H 104 | docs/algorithms/queue.md,0/8/0858fcad5aeba51c7ac2e3acdce84df6912d9c3b 105 | I 106 | docs/algorithms/string.md,a/c/ac6768fd34f9d6447e00f673b336a0c3192cd131 107 | V 108 | &docs/algorithms/dynamic-programming.md,a/2/a21391f3c3f284771010826798b24faddbaddd21 109 | L 110 | docs/algorithms/intergers.md,1/0/10eb7d7188f1cbc875263bdbb0e23d90f766d836 111 | Q 112 | !docs/algorithms/data-structure.md,1/1/11dc0031e207270142fbe0a210e7f3d9628feeeb 113 | N 114 | docs/algorithms/linked-list.md,7/0/70516a2103d45e3a7280cf61d048453c5d327688 -------------------------------------------------------------------------------- /docs/ui/angular/angular-http-interceptor.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Angular http Interceptor 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular http Interceptor interview questions and answers." 8 | categories: [Angular http Interceptor] 9 | --- 10 | 11 | # Angular http Interceptor 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | ## What is Angular Http Interceptor? 25 | 26 | * An Angular HTTP interceptor is a powerful feature that allows you to intercept and modify HTTP requests and responses. It is a way to centralize the handling of certain aspects of an HTTP request, such as adding headers, handling errors, or modifying the request and response. 27 | 28 | * An HTTP interceptor is a service that implements the HttpInterceptor interface, which defines a single method intercept(req: HttpRequest, next: HttpHandler) : Observable>. This method is called for each HTTP request, and it receives the current request and a next object, which is used to execute the next interceptor or the final request. 29 | 30 | Here is an **example** of how to **create** an HTTP interceptor that adds a custom header to all requests: 31 | 32 | ```log 33 | import { Injectable } from '@angular/core'; 34 | import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; 35 | import { Observable } from 'rxjs'; 36 | 37 | @Injectable() 38 | export class AuthInterceptor implements HttpInterceptor { 39 | 40 | intercept(req: HttpRequest, next: HttpHandler): Observable> { 41 | // Clone the request and add the new header 42 | const authReq = req.clone({ headers: req.headers.set('Authorization', 'Bearer YOUR_TOKEN') }); 43 | 44 | // Pass the cloned request to the next handle 45 | return next.handle(authReq); 46 | } 47 | } 48 | ``` 49 | 50 | You then need to register the interceptor in your **app.module.ts** file by adding it to the providers array and the `HTTP_INTERCEPTORS` multi-provider. 51 | 52 | ```log 53 | import { AuthInterceptor } from './auth.interceptor'; 54 | 55 | @NgModule({ 56 | ... 57 | providers: [ 58 | { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true } 59 | ], 60 | ... 61 | }) 62 | ``` 63 | 64 | * HTTP interceptors can be used for a variety of tasks, such as adding headers, handling errors, logging, caching, or modifying the request and response. 65 | 66 | * It's worth mentioning that you can also create multiple interceptors, each one with a specific task, and chain them together to handle multiple aspects of an HTTP request. 67 | 68 | In summary, an Angular HTTP interceptor is a powerful feature that allows you to intercept and modify HTTP requests and responses, it allows you to centralize the handling of certain aspects of an HTTP request and enables you to handle multiple aspects of an HTTP request by chaining multiple interceptors. 69 | 70 | ### How to Add interceptor to providers? 71 | 72 | In Angular, you can add interceptors to your application's providers by first importing the HTTP_INTERCEPTORS token and the interceptor class. Then, in your application's module, you can add the interceptor class to the providers array, along with the HTTP_INTERCEPTORS token. 73 | 74 | Here is an example: 75 | 76 | 1. Import the necessary modules in your interceptor file: 77 | 78 | ```log 79 | import { Injectable } from '@angular/core'; 80 | import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; 81 | ``` 82 | 83 | 2. Create the interceptor class and implement the HttpInterceptor interface: 84 | 85 | ```log 86 | @Injectable() 87 | export class MyInterceptor implements HttpInterceptor { 88 | intercept(req: HttpRequest, next: HttpHandler): Observable> { 89 | // Add your interceptor logic here 90 | } 91 | } 92 | ``` 93 | 94 | 3. In your **app.module.ts**, import the HTTP_INTERCEPTORS token and the interceptor class: 95 | 96 | ```log 97 | import { HTTP_INTERCEPTORS } from '@angular/common/http'; 98 | import { MyInterceptor } from './interceptors/my-interceptor'; 99 | ``` 100 | 101 | 4. Add the interceptor class to the providers array, along with the HTTP_INTERCEPTORS token: 102 | 103 | ```log 104 | @NgModule({ 105 | providers: [ 106 | { 107 | provide: HTTP_INTERCEPTORS, 108 | useClass: MyInterceptor, 109 | multi: true 110 | } 111 | ] 112 | }) 113 | export class AppModule { } 114 | 115 | ``` 116 | 117 | **Note:** The multi: true is added so that multiple interceptors can be added. 118 | 119 | ### Any interceptor we want to create needs to implement the HttpInterceptor interface. 120 | 121 | * This means that our new class should have a method called intercept with parameters HttpRequest and HttpHandler. The use of interceptors transforms outgoing requests and incoming responses, but we cannot tamper with the original request - it has to be immutable. To make changes, we need to clone the original request. 122 | 123 | * As we clone the original request, we can set any header we want. In our case, it's very simple - we want to add an Authorization header with an auth scheme of Bearer after the JSON Web Token in local storage, which we get from the AuthService by calling the getToken method. 124 | 125 | --- 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /docs/devops/linux.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Linux 4 | parent: DevOps 5 | resource: true 6 | desc: "Linux interview questions and answers." 7 | categories: [Linux] 8 | --- 9 | 10 | # Linux 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Find 25 | 26 | 27 | - `find dir -type f` Find all files in the directory 28 | - `find dir -type d` File all directories within this directory 29 | - `find dir -name "a*.mp3" -print0` Find all files/directory with name like a***.mp3 30 | - `find dir -type f -name "a*.txt"` Find all files (recursively) with name like a***.txt 31 | - `find dir -type f -print0 | xargs -0 grep -l "word"` List file names with matching word 32 | - `find dir -type f -print0 | xargs -0 mv -t` Move all files from dir tree into single directory 33 | 34 | --- 35 | 36 | ## Search 37 | 38 | - `grep "word" file` All matching lines in the file 39 | - `grep -i "word" file` All matching lines - Ignore case 40 | - `grep -r "word" dir` All matching lines in (recursively) all files or directory 41 | - `grep -c "word" file` Count of matching lines 42 | - `grep "word" file | wc -l` Count of matching lines 43 | - `grep -v "word" file | wc -l` Count of non-matching lines 44 | - `grep -o -w "word" file | wc -w` Word count 45 | - `grep -l -r "word" dir` List file names with matching word 46 | - `find dir -type f -print0 | xargs -0 grep -l "word"` List file names with matching word 47 | 48 | --- 49 | 50 | ## Processes 51 | 52 | - `nohup program.sh > mylog.txt 2>&1 &` 53 | + `&` starts process as child process in the background 54 | + `nohup` Ctrl-C or terminating session sends kill signal to all child processes, `nohup` catches and ignores it 55 | + `>` redirect output (from left/source to right/target) 56 | + `2` error stream 57 | + `1` output stream 58 | + `2>&1` append all errors to output 59 | - `top` Check CPU and memory consumption 60 | - `kill -9 processId` kill the process with that pid 61 | - `kill -3 processId` for a JVM process, will write thread dump to output stream 62 | - `ps -ef | grep word` find process with matching word 63 | - `echo $?` print output of last process 64 | 65 | --- 66 | 67 | ## File permissions 68 | 69 | 70 | - `chmod file` Change 71 | - `chmod +x file` Add execute permission 72 | - `chmod +w file` Add write permission 73 | - `chmod +r file` Add read permission 74 | - `chmod 755 file` Change permission 75 | - `chmod -R 755 dir` Change permission recursively 76 | - `chmod g+w file` Add write permission at group level 77 | - Numbers: 1=x, 2=w, 3=w+x, 4=r, 5=r+x, 6=r+w, 7=r+w+x 78 | - References: u=user, g=group, o=others, a=all 79 | 80 | --- 81 | 82 | ## List files 83 | 84 | 85 | - `ls` list files in this directory 86 | - `ls -ltr` list files in this directory with more details and in reverse chronological order 87 | - `ls -ltra` same as above + list hidden files (names starting with `.`) 88 | - `ls -ltr | grep "^l"` Lists all symlinks (`ls -ltr` lists symlinks with `l` as first character of output) 89 | 90 | --- 91 | 92 | ## Symlinks 93 | 94 | 95 | - Symbolic or soft links. Pointer to a file. 96 | - `ln -s /java/jdk7 jdk` create symlink jdk which points to `/java/jdk7` 97 | - `ln -ns /java/jdk8 jdk` update symlink jdk to point to `/java/jdk8` 98 | 99 | 100 | --- 101 | 102 | ## Checking logs 103 | 104 | 105 | - `tail -f logfile` output appended data as file grows (f=follow) 106 | - `less +F logfile` open file, and output appended data as file grows 107 | 108 | --- 109 | 110 | ## Text manipulation 111 | 112 | 113 | - `head file` display first 10 lines 114 | - `head -20 file` display first 20 lines 115 | - `tail file` display last 10 lines 116 | - `tail -5 file` display last 5 lines 117 | - `head -20 file | tail -1` display 20th line 118 | - `cut -f3 file` display 3rd field for each line, tab as separator 119 | - `cut -d',' -f3 file` display 3rd field for each line, `,` as separator 120 | - `cut -c3-6 file` display characters from 3rd to 6th position for each line 121 | - `cut -c7- file` display characters from 7th to end of each line 122 | 123 | --- 124 | 125 | ## Sed 126 | 127 | 128 | - `sed s/unix/linux file` replace first occurrence of "unix with "linux" 129 | - `sed s/unix/linux/3 file` replace 3rd occurrence 130 | - `sed s/unix/linux/g file` replace all occurrences 131 | - `sed s/unix/linux/3g file` replace all occurrences starting from 3rd one 132 | - `sed -i '1 d' file` delete header of file 133 | - `sed -i '$ d' file` delete footer of file 134 | - `sed –n '10 p' file` print 10th line of the file 135 | 136 | --- 137 | 138 | ## Networking 139 | 140 | 141 | - `ping hostname` or `telnet hostname port` check if remote host is alive 142 | - `scp /dir/file user@hostname:/targetdir/file` copy file to different host 143 | - `netstat -a | grep "port"` check host connected to machine's port 144 | 145 | --- 146 | 147 | ## Space 148 | 149 | 150 | - `df -h` space in current drive (`-h` is human readable format) 151 | - `du -h .` sizes of all files in current directory 152 | - `du -sh .` sizes of current directory 153 | - `du /bin/* | sort -n` sort all files based on size (asc) 154 | 155 | 156 | --- 157 | 158 | ## Miscellaneous 159 | 160 | 161 | - `lsof file` list processes using the file 162 | - `rev file` reverses the text in each line 163 | - `echo "string" | rev ` reverses the string 164 | - `sort file` sorts file lines alphabetically 165 | - `sort -n file` sorts file lines numerically 166 | - `uniq file` filter out adjacent duplicate lines and print 167 | - `uniq -c file` print with count at the begining of each line of output 168 | - `uniq -d file` print only duplicates 169 | 170 | 171 | --- 172 | 173 | ## For more information 174 | 175 | - [Art of Command Line](https://github.com/jlevy/the-art-of-command-line#processing-files-and-data) -------------------------------------------------------------------------------- /docs/ui/angular/angular-lifecycle-hooks.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Lifecycle Hooks 4 | parent: Angular 5 | resource: true 6 | grand_parent: UI Design 7 | desc: "Angular Lifecycle Hooks interview questions and answers." 8 | categories: [Angular Lifecycle Hooks] 9 | --- 10 | 11 | # Angular Lifecycle Hooks 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | --- 26 | 27 | ## Angular Lifecycle Hooks 28 | 29 | ### Ans1 30 | 31 | Angular 12 provides a set of lifecycle hooks that allow you to tap into different phases of a component's lifecycle and perform custom logic. 32 | 33 | The following are the lifecycle hooks available in Angular 12: 34 | 35 | - **ngOnChanges** − This hook is called when one or more of the input properties of a component change. It is used to update the component's internal state and re-render the view if necessary. 36 | 37 | ```typescript 38 | ngOnChanges(changes: SimpleChanges) { 39 | console.log(changes); 40 | } 41 | 42 | ``` 43 | 44 | 45 | - **ngOnInit** − This hook is called after the first ngOnChanges and it is used to initialize the component's state. This is a good place to make API calls or other initialization logic. 46 | 47 | ```typescript 48 | ngOnInit() { 49 | console.log("Component initialized"); 50 | } 51 | 52 | 53 | ``` 54 | - **ngDoCheck** − This hook is called during every change detection cycle and it is used to check for and act on changes that Angular can't detect on its own. 55 | 56 | ```typescript 57 | ngDoCheck() { 58 | console.log("Checking for changes"); 59 | } 60 | 61 | 62 | ``` 63 | 64 | - **ngAfterContentInit** −This hook is called after the component's content has been initialized and projected into the view. It is used to interact with the projected content. 65 | 66 | ```typescript 67 | ngAfterContentInit() { 68 | console.log("Content initialized"); 69 | } 70 | 71 | 72 | ``` 73 | 74 | - **ngAfterContentChecked**− This hook is called after every change detection cycle that affects the component's content. 75 | 76 | ```typescript 77 | ngAfterContentChecked() { 78 | console.log("Content checked"); 79 | } 80 | 81 | 82 | ``` 83 | 84 | - **ngAfterViewInit** − This hook is called after the component's view and child views have been initialized. It is used to interact with the initialized views. 85 | 86 | 87 | ```typescript 88 | ngAfterViewInit() { 89 | console.log("View initialized"); 90 | } 91 | 92 | 93 | ``` 94 | 95 | - **ngAfterViewChecked** −This hook is called after every change detection cycle that affects the component's view. 96 | 97 | 98 | ```typescript 99 | ngAfterViewChecked() { 100 | console.log("View checked"); 101 | } 102 | 103 | 104 | ``` 105 | 106 | - **ngOnDestroy** − This hook is called just before a component is destroyed. It is used to clean up any resources or subscriptions that the component has created. 107 | 108 | ```typescript 109 | ngOnDestroy() { 110 | console.log("Component destroyed"); 111 | } 112 | 113 | 114 | ``` 115 | 116 | This hook is called just before Angular destroys the component. You can use it to perform any necessary cleanup operations. 117 | 118 | ```typescript 119 | ngOnDestroy() { 120 | this.subscription.unsubscribe(); 121 | } 122 | 123 | 124 | ``` 125 | 126 | 127 | ### Ans2 128 | Angular creates and renders components along with their children, checks when their data-bound properties change, and destroys them before removing them from the DOM. 129 | 130 | Angular offers lifecycle hooks that provide visibility into these key life moments and the ability to act when they occur. 131 | 132 | Angular 2 application goes through an entire set of processes or has a lifecycle right from its initiation to the end of the application. 133 | 134 | The hooks are executed in this order: 135 | 136 | 137 | 138 | Description of each lifecycle hook. 139 | 140 | - **ngOnChanges** − When the value of a data bound property changes, then this method is called. 141 | - **ngOnInit** − This is called whenever the initialization of the directive/component after Angular first displays the data-bound properties happens. 142 | - **ngDoCheck** − This is for the detection and to act on changes that Angular can't or won't detect on its own. 143 | - **ngAfterContentInit** − This is called in response after Angular projects external content into the component's view. 144 | - **ngAfterContentChecked**− This is called in response after Angular checks the content projected into the component. 145 | - **ngAfterViewInit** − This is called in response after Angular initializes the component's views and child views. 146 | - **ngAfterViewChecked** − This is called in response after Angular checks the component's views and child views. 147 | - **ngOnDestroy** − This is the cleanup phase just before Angular destroys the directive/component. 148 | 149 | --- 150 | 151 | ## constructor() vs ngOnInit() 152 | 153 | TypeScript classes has a default method called `constructor()` which is normally used for the initialization purpose. Whereas `ngOnInit()` method is specific to Angular, especially used to define Angular bindings. Even though `constructor()` getting called first, it is preferred to use `ngOnInit()` method for Angular bindings. 154 | 155 | Example 156 | 157 | ```typescript 158 | export class App implements OnInit{ 159 | constructor(){ 160 | //called first time before the ngOnInit() 161 | } 162 | 163 | ngOnInit(){ 164 | //called after the constructor and called after the first ngOnChanges() 165 | } 166 | } 167 | ``` 168 | --- 169 | 170 | ## For more information 171 | 1. [Angular Lifecycle Hooks: ngOnChanges, ngOnInit, and more](https://www.freecodecamp.org/news/angular-lifecycle-hooks/) 172 | 2. [Angular 2 - Lifecycle Hooks](https://www.tutorialspoint.com/angular2/angular2_lifecycle_hooks.htm) 173 | 3. [Angular lifecycle hooks explained](https://blog.logrocket.com/angular-lifecycle-hooks/) 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/spring/security/security.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Security 3 | parent: Spring 4 | has_children: true 5 | resource: true 6 | nav_order: 3 7 | desc: "Security interview questions and answers." 8 | categories: [Security] 9 | --- 10 | 11 | # Security 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | 26 | --- 27 | 28 | ## Spring Security 29 | 30 | Spring Security is essentially just a bunch of servlet filters that enable Java applications to include authentication and authorization functionality. It is one of the most powerful, and highly customizable access-control frameworks (security framework) that provide authentication, authorization, and other security features for Java EE (Enterprise edition) based enterprise applications. The real power of Spring Security lies in its ability to be extended to meet custom needs. Its main responsibility is to authenticate and authorize incoming requests for accessing any resource, including rest API endpoints, MVC (Model-View-Controller) URLs, static resources, etc. 31 | 32 | 33 | ### Features of Spring Security 34 | 35 | Some essential features of Spring Security include: 36 | 37 | - Supports authentication and authorization in a flexible and comprehensive manner. 38 | - Detection and prevention of attacks including session fixation, clickjacking, cross-site request forgery, etc. 39 | - Integrate with Servlet API. 40 | - Offers optional integration with Spring Web MVC (Model-View-Controller). 41 | - Java Authentication and Authorization Service (JAAS) is used for authentication purposes. 42 | - Allows Single Sign-On so that users can access multiple applications with just one account (username and password). 43 | 44 | ### Authentication and Authorization 45 | 46 | #### Authentication: 47 | This refers to the process of verifying the identity of the user, using the credentials provided when accessing certain restricted resources. Two steps are involved in authenticating a user, namely identification and verification. An example is logging into a website with a username and a password. This is like answering the question Who are you? 48 | #### Authorization: 49 | It is the ability to determine a user's authority to perform an action or to view data, assuming they have successfully logged in. This ensures that users can only access the parts of a resource that they are authorized to access. It could be thought of as an answer to the question Can a user do/read this? 50 | 51 | 52 | --- 53 | 54 | ## Authentication Types 55 | 56 | ### Basic authentication 57 | 58 | RESTful web services can be authenticated in many ways, but the most basic one is basic authentication. For basic authentication, we send a username and password using the HTTP [Authorization] header to enable us to access the resource. Usernames and passwords are encoded using base64 encoding (not encryption) in Basic Authentication. The encoding is not secure since it can be easily decoded. 59 | 60 | Syntax: 61 | 62 | 63 | ```log 64 | Value = username:password 65 | Encoded Value = base64(Value) 66 | Authorization Value = Basic 67 | //Example: Authorization: Basic VGVzdFVzZXI6dGVzdDEyMw== 68 | //Decode it'll give back the original username:password UserName:user123 69 | ``` 70 | 71 | ### digest authentication 72 | 73 | RESTful web services can be authenticated in many ways, but advanced authentication methods include digest authentication. It applies a hash function to username, password, HTTP method, and URI in order to send credentials in encrypted form. It generates more complex cryptographic results by using the hashing technique which is not easy to decode. 74 | 75 | Syntax: 76 | 77 | ```log 78 | Hash1=MD5(username:realm:password) 79 | Hash2=MD5(method:digestURI) 80 | response=MD5(Hash1:nonce:nonceCount:cnonce:qop:Hash2) 81 | //Example, this got generated by running this example 82 | Authorization: Digest username="TestAdmin", realm="admin-digest-realm", nonce="MTYwMDEwMTUyMDM4OToxM2M1Y2I4MGFjMjk4OGI1ODQzZjc3NDUzOGFlMjZjYw==", uri="/admin/hello?name=User", response="2f080edbec53be2bdf3853d477e4a543", qop=auth, nc=00000002, cnonce="11ecd9bf947dbcf4" 83 | ``` 84 | 85 | 86 | --- 87 | 88 | ## Spring Security Modules 89 | 90 | In Spring Security, the Security module comprises separate jar files based on its functionality. The primary use is to allow the user to integrate according to the requirements. To include minimal spring security for your Maven project, include below dependencies in your pom.xml. 91 | 92 | **Core – spring-security-core.jar** 93 | - This module contains core authentication and access-control related classes, basic provisioning APIs. This is mandatory for providing spring security to any J2EE based enterprise application. This module supports non-web applications, too. 94 | 95 | **Web – spring-security-web.jar** 96 | –This module contains filters and web-based authentication, like access control for URLs in a Servlet environment. This module is responsible to provide security to your Spring MVC or any other web application. 97 | 98 | **Config- spring-security-config.jar** 99 | –This module used to use the Spring Security XML name-space. It also supports. 100 | 101 | **LDAP** 102 | – Modules supporting the LDAP authentication. We may need this if you want to have LDAP authentication for our application. 103 | 104 | **OAuth 2.0 Core** 105 | – Provides support for the OAuth 2.0 authorization. 106 | 107 | **OAuth 2.0 Client** 108 | – Spring Security’s client support for OAuth 2.0 Authorization Framework and OpenID Connect Core 1.0. 109 | 110 | **Secure:** 111 | 112 | Spring has provided a separate module for securing the application. Spring Security is a Java SE/Java EE security framework to provide Authentication, Authorization, SSO and other Security features for Web Applications or Enterprise Applications. Spring Security supports the various types of security such as : 113 | 114 | 1. Authentication and Authorization. 115 | 2. BASIC,Digest and Form-Based Authentication. 116 | 3. LDAP Authentication. 117 | 4. OpenID Authentication. 118 | 5. SSO (Single Sign-On) Implementation. 119 | 6. Cross-Site Request Forgery (CSRF) Implementation. 120 | 7. `Remember-Me` Feature through HTTP Cookies. 121 | 8. Implementation of ACLs. 122 | 9. `Channel Security` that means automatically switching between HTTP and HTTPS. 123 | 10. JAAS (Java Authentication and Authorization Service). 124 | 11. Flow Authorization using Spring WebFlow Framework. 125 | 12. WS-Security using Spring Web Services. 126 | 127 | 128 | -------------------------------------------------------------------------------- /docs/spring/spring-security.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Spring Security 4 | parent: Spring 5 | resource: true 6 | desc: "Spring Cloud interview questions and answers." 7 | categories: [Spring Security] 8 | --- 9 | 10 | 11 | # Spring Security 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | ## Introducing Spring Security 26 | 27 | Spring Security is essentially just a bunch of servlet filters that enable Java applications to include authentication and authorization functionality. It is one of the most powerful, and highly customizable access-control frameworks (security framework) that provide authentication, authorization, and other security features for Java EE (Enterprise edition) based enterprise applications. The real power of Spring Security lies in its ability to be extended to meet custom needs. Its main responsibility is to authenticate and authorize incoming requests for accessing any resource, including rest API endpoints, MVC (Model-View-Controller) URLs, static resources, etc. 28 | 29 | 30 | ### Features of Spring Security 31 | 32 | Some essential features of Spring Security include: 33 | 34 | - Supports authentication and authorization in a flexible and comprehensive manner. 35 | - Detection and prevention of attacks including session fixation, clickjacking, cross-site request forgery, etc. 36 | - Integrate with Servlet API. 37 | - Offers optional integration with Spring Web MVC (Model-View-Controller). 38 | - Java Authentication and Authorization Service (JAAS) is used for authentication purposes. 39 | - Allows Single Sign-On so that users can access multiple applications with just one account (username and password). 40 | 41 | ### Authentication and Authorization 42 | 43 | #### Authentication: 44 | This refers to the process of verifying the identity of the user, using the credentials provided when accessing certain restricted resources. Two steps are involved in authenticating a user, namely identification and verification. An example is logging into a website with a username and a password. This is like answering the question Who are you? 45 | #### Authorization: 46 | It is the ability to determine a user's authority to perform an action or to view data, assuming they have successfully logged in. This ensures that users can only access the parts of a resource that they are authorized to access. It could be thought of as an answer to the question Can a user do/read this? 47 | 48 | 49 | --- 50 | 51 | ## Authentication Types 52 | 53 | ### Basic authentication 54 | 55 | RESTful web services can be authenticated in many ways, but the most basic one is basic authentication. For basic authentication, we send a username and password using the HTTP [Authorization] header to enable us to access the resource. Usernames and passwords are encoded using base64 encoding (not encryption) in Basic Authentication. The encoding is not secure since it can be easily decoded. 56 | 57 | Syntax: 58 | 59 | 60 | ```log 61 | Value = username:password 62 | Encoded Value = base64(Value) 63 | Authorization Value = Basic 64 | //Example: Authorization: Basic VGVzdFVzZXI6dGVzdDEyMw== 65 | //Decode it'll give back the original username:password UserName:user123 66 | ``` 67 | 68 | ### digest authentication 69 | 70 | RESTful web services can be authenticated in many ways, but advanced authentication methods include digest authentication. It applies a hash function to username, password, HTTP method, and URI in order to send credentials in encrypted form. It generates more complex cryptographic results by using the hashing technique which is not easy to decode. 71 | 72 | Syntax: 73 | 74 | ```log 75 | Hash1=MD5(username:realm:password) 76 | Hash2=MD5(method:digestURI) 77 | response=MD5(Hash1:nonce:nonceCount:cnonce:qop:Hash2) 78 | //Example, this got generated by running this example 79 | Authorization: Digest username="TestAdmin", realm="admin-digest-realm", nonce="MTYwMDEwMTUyMDM4OToxM2M1Y2I4MGFjMjk4OGI1ODQzZjc3NDUzOGFlMjZjYw==", uri="/admin/hello?name=User", response="2f080edbec53be2bdf3853d477e4a543", qop=auth, nc=00000002, cnonce="11ecd9bf947dbcf4" 80 | ``` 81 | 82 | 83 | --- 84 | 85 | ## Spring Security Modules 86 | 87 | In Spring Security, the Security module comprises separate jar files based on its functionality. The primary use is to allow the user to integrate according to the requirements. To include minimal spring security for your Maven project, include below dependencies in your pom.xml. 88 | 89 | **Core – spring-security-core.jar** 90 | - This module contains core authentication and access-control related classes, basic provisioning APIs. This is mandatory for providing spring security to any J2EE based enterprise application. This module supports non-web applications, too. 91 | 92 | **Web – spring-security-web.jar** 93 | –This module contains filters and web-based authentication, like access control for URLs in a Servlet environment. This module is responsible to provide security to your Spring MVC or any other web application. 94 | 95 | **Config- spring-security-config.jar** 96 | –This module used to use the Spring Security XML name-space. It also supports. 97 | 98 | **LDAP** 99 | – Modules supporting the LDAP authentication. We may need this if you want to have LDAP authentication for our application. 100 | 101 | **OAuth 2.0 Core** 102 | – Provides support for the OAuth 2.0 authorization. 103 | 104 | **OAuth 2.0 Client** 105 | – Spring Security’s client support for OAuth 2.0 Authorization Framework and OpenID Connect Core 1.0. 106 | 107 | **Secure:** 108 | 109 | Spring has provided a separate module for securing the application. Spring Security is a Java SE/Java EE security framework to provide Authentication, Authorization, SSO and other Security features for Web Applications or Enterprise Applications. Spring Security supports the various types of security such as : 110 | 111 | 1. Authentication and Authorization. 112 | 2. BASIC,Digest and Form-Based Authentication. 113 | 3. LDAP Authentication. 114 | 4. OpenID Authentication. 115 | 5. SSO (Single Sign-On) Implementation. 116 | 6. Cross-Site Request Forgery (CSRF) Implementation. 117 | 7. `Remember-Me` Feature through HTTP Cookies. 118 | 8. Implementation of ACLs. 119 | 9. `Channel Security` that means automatically switching between HTTP and HTTPS. 120 | 10. JAAS (Java Authentication and Authorization Service). 121 | 11. Flow Authorization using Spring WebFlow Framework. 122 | 12. WS-Security using Spring Web Services. 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /docs/spring/swagger-docs.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Swagger 4 | parent: Spring 5 | resource: true 6 | desc: "Swagger interview questions and answers." 7 | categories: [Swagger] 8 | --- 9 | 10 | # Swagger 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | Swagger is a very good open source tool for documenting REST based APIs provided by microservices. It provides very easy to use interactive documentation. 25 | 26 | By the use of swagger annotation on REST endpoint, api documentation can be autogenerated and exposed over the web interface. Internal and external team can use web interface, to see the list of APIs and their inputs & error codes. They can even invoke the endpoints directly from web interface to get the results. 27 | 28 | Swagger UI is a very powerful tool for your microservices consumers to help them understand set of endpoints provided by a given microservice. 29 | 30 | ## Integrate Swagger into your microservices 31 | 32 | Integrating swagger into Spring Boot based application should be straight forward. You need to add swagger dependencies into `build.gradle`, provide swagger configuration and finally make some tweaks into WebMvcConfig to allow swagger-ui into your project. 33 | 34 | **build.gradle - add swagger dependencies.** 35 | ```xml 36 | dependencies { 37 | compile('org.springframework.cloud:spring-cloud-starter-config') 38 | // https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 39 | compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0' 40 | compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0' 41 | ``` 42 | 43 | **Second step is to define swagger configuration:** 44 | SwaggerConfig.java. 45 | ```java 46 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 47 | import org.springframework.context.annotation.*; 48 | import springfox.documentation.builders.*; 49 | import springfox.documentation.service.*; 50 | 51 | @Configuration 52 | @EnableSwagger2 53 | @EnableAutoConfiguration 54 | public class SwaggerConfig { 55 | @Bean 56 | public Docket productApi() { 57 | return new Docket(DocumentationType.SWAGGER_2) 58 | .groupName("Product Service") 59 | .apiInfo(apiInfo()) 60 | .select() 61 | .apis(RequestHandlerSelectors.basePackage("hello")) 62 | .paths(PathSelectors.any()) 63 | .build(); 64 | } 65 | private ApiInfo apiInfo() { 66 | return new ApiInfoBuilder() 67 | .title("Product Service with Swagger") 68 | .description("Spring REST Sample with Swagger") 69 | .termsOfServiceUrl("http://www-03.ibm.com/software/sla/sladb.nsf/sla/bm?Open") 70 | .contact(new Contact("Munish Chandel", "","munish.chandel@outlook.com")) 71 | .license("Apache License Version 2.0") 72 | .licenseUrl("https://github.com/IBM-Bluemix/news-aggregator/blob/master/LICENSE") 73 | .version("1.0") 74 | .build(); 75 | } 76 | } 77 | 78 | ``` 79 | **Lastly, add the below WebMvcConfig to enable swagger UI** 80 | 81 | ```java 82 | import org.slf4j.Logger; 83 | import org.slf4j.LoggerFactory; 84 | import org.springframework.context.annotation.Configuration; 85 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 86 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 87 | 88 | @Configuration 89 | public class WebMvcConfig extends WebMvcConfigurerAdapter { 90 | private static final Logger logger = LoggerFactory.getLogger(WebMvcConfig.class); 91 | @Override 92 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 93 | super.addResourceHandlers(registry); 94 | registry.addResourceHandler("swagger-ui.html") 95 | .addResourceLocations("classpath:/META-INF/resources/"); 96 | /*registry.addResourceHandler("/webjars/**") 97 | .addResourceLocations("classpath:/META-INF/resources/webjars/");*/ 98 | } 99 | } 100 | 101 | ``` 102 | Now swagger is configured for use in your application. 103 | 104 | 105 | 106 | ## Swagger annotations 107 | 108 | Then the resource class can have annotations such as: 109 | 110 | - `@Api`: To mark a resource as a Swagger resource 111 | - `@ApiOperation`: Describes an operation or typically an HTTP method against a specific path 112 | - `@ApiResponse`: To describe the response of a method 113 | - `@ApiParam`: Additional metadata for operational parameters of a method 114 | 115 | ## Maven plugin 116 | 117 | A Maven plugin can be used to generate the swagger.yaml file based on the metadata placed on the code: 118 | ```xml 119 | 120 | ... 121 | 122 | com.github.kongchen 123 | swagger-maven-plugin 124 | 3.1.5 125 | 126 | 127 | 128 | false 129 | org.jee8ng.users.boundary 130 | http 131 | localhost:8081 132 | /${project.build.finalName}/resources 133 | 134 | 135 | Users API 136 | v1 137 | Users rest endpoints 138 | 139 | yaml 140 | ${basedir}/src/main/webapp 141 | 142 | 143 | 144 | 145 | 146 | 147 | compile 148 | 149 | generate 150 | 151 | 152 | 153 | 154 | ... 155 | 156 | ``` 157 | 158 | The swaggerDirectory is where the `swagger.yaml` file gets generated. This way, it's possible to use a combination of plugins and annotations to create the Swagger Spec format with the desired output, such as JSON, configured here. The plugin and API details can be explored further on the Swagger website and on the GitHub pages of the plugin. 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /docs/aws/api-gateway.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: API Gateway 4 | parent: AWS 5 | resource: true 6 | desc: " AWS API Gateway interview questions and answers." 7 | categories: [API Gateway] 8 | 9 | --- 10 | 11 | # AWS API Gateway 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | 26 | ## API Gateway 27 | 28 | 29 | API Gateway is a fully managed service for developers that makes it easy to build, publish, manage, and secure entire APIs. With a few clicks in the AWS Management Console, you can create an API that acts as a “front door” for applications to access data, business logic, or functionality from your back-end services, such as workloads running on EC2) code running on AWS Lambda, or any web application. 30 | 31 | ### API Gateway Key Details 32 | - Amazon API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, authorization and access control, monitoring, and API version management. 33 | - Amazon API Gateway has no minimum fees or startup costs. You pay only for the API calls you receive and the amount of data transferred out. 34 | - API Gateway does the following for your APIs: 35 | - Exposes HTTP(S) endpoints for RESTful functionality 36 | - Uses serverless functionality to connect to Lambda & DynamoDB 37 | - Can send each API endpoint to a different target 38 | - Runs cheaply and efficiently 39 | - Scales readily and effortlessly 40 | - Can throttle requests to prevent attacks 41 | - Track and control usage via an API key 42 | - Can be version controlled 43 | - Can be connected to CloudWatch for monitoring and observability 44 | - Since API Gateway can function with AWS Lambda, you can run your APIs and code without needing to maintain servers. 45 | - Amazon API Gateway provides throttling at multiple levels including global and by a service call. 46 | - In software, a throttling process, or a throttling controller as it is sometimes called, is a process responsible for regulating the rate at which application processing is conducted, either statically or dynamically. 47 | - Throttling limits can be set for standard rates and bursts. For example, API owners can set a rate limit of 1,000 requests per second for a specific method in their REST APIs, and also configure Amazon API Gateway to handle a burst of 2,000 requests per second for a few seconds. 48 | - Amazon API Gateway tracks the number of requests per second. Any requests over the limit will receive a 429 HTTP response. The client SDKs generated by Amazon API Gateway retry calls automatically when met with this response. 49 | - You can add caching to API calls by provisioning an Amazon API Gateway cache and specifying its size in gigabytes. The cache is provisioned for a specific stage of your APIs. This improves performance and reduces the traffic sent to your back end. Cache settings allow you to control the way the cache key is built and the time-to-live (TTL) of the data stored for each method. Amazon API Gateway also exposes management APIs that help you invalidate the cache for each stage. 50 | - You can enable API caching for improving latency and reducing I/O for your endpoint. 51 | - When caching for a particular API stage (version controlled version), you cache responses for a particular TTL in seconds. 52 | - API Gateway supports AWS Certificate Manager and can make use of free TLS/SSL certificates. 53 | - With API Gateway, there are two kinds of API calls: 54 | - Calls to the API Gateway API to create, modify, delete, or deploy REST APIs. These are logged in CloudTrail. 55 | - API calls set up by the developers to deliver their custom functionality: These are not logged in CloudTrail. 56 | 57 | ### API Gateway 58 | 59 | Amazon Web Services (AWS) API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. 60 | 61 | API Gateway enables developers to build RESTful APIs, WebSocket APIs, and HTTP APIs that act as a “front door” for applications to access data, business logic, or functionality from backend services. Developers can use API Gateway to create APIs that integrate with AWS Lambda, AWS Elastic Beanstalk, Amazon EC2, or any publicly accessible web service. 62 | 63 | API Gateway provides a number of features that make it easy to manage APIs. These features include: 64 | 65 | `API creation and management`: Developers can use the API Gateway console or API to create and manage APIs, define resources and methods, and set up authentication and authorization. 66 | 67 | `Integration with AWS services`: API Gateway can be integrated with AWS services such as Lambda, Elastic Beanstalk, and EC2 to create a scalable and reliable backend for APIs. 68 | 69 | `Security and access control`: API Gateway provides a number of features for securing APIs, including support for OAuth 2.0 and JSON Web Tokens (JWTs), and integration with AWS Identity and Access Management (IAM). 70 | 71 | `Monitoring and logging`: API Gateway provides detailed metrics and logging for APIs, allowing developers to monitor API usage, identify issues, and troubleshoot problems. 72 | 73 | `API deployment and scaling`: API Gateway makes it easy to deploy APIs to multiple stages (e.g., development, testing, production), and provides automatic scaling to handle changes in API traffic. 74 | 75 | 76 | ### Configure API using AWS API Gateway with AWS Lambda as a backend 77 | 78 | - Create a Lambda function: First, create a Lambda function that will act as the backend for your API. You can do this using the AWS Management Console or the AWS CLI. For example, you could create a function that retrieves data from a database or performs some other business logic. 79 | 80 | - Create an API Gateway: Next, create an API Gateway using the AWS Management Console or the AWS CLI. You'll need to define a REST API and configure its resources and methods. For example, you could define a GET method on the "/users" resource that retrieves a list of users from your Lambda function. 81 | 82 | - Set up integration between API Gateway and Lambda: Once you've created your API Gateway, you need to set up integration between API Gateway and your Lambda function. You can do this using the AWS Management Console or the AWS CLI. For example, you could set up a Lambda Proxy integration that maps incoming requests to your Lambda function and returns the function's output to the client. 83 | 84 | - Add security to your API: To secure your API, you can use API Gateway's built-in support for OAuth 2.0 and JSON Web Tokens (JWTs), or you can integrate with AWS Identity and Access Management (IAM) to control access to your API. 85 | 86 | - Deploy your API: Once you've configured your API, you can deploy it to a specific stage (e.g., development, testing, production). You can do this using the AWS Management Console or the AWS CLI. 87 | 88 | - Test your API: Finally, test your API to make sure it's working as expected. You can do this using a tool like Postman or by sending requests directly from your client application. 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/database/mongo-db.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: MongoDB 4 | parent: Database 5 | resource: true 6 | desc: " MongoDB interview questions and answers." 7 | categories: [MongoDB] 8 | --- 9 | 10 | # MongoDB 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | 25 | Wikipedia describes as 26 | > MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). 27 | 28 | - MongoDB is an open-source NoSQL database written in C++ language. It uses JSON-like documents with optional schemas. 29 | - It provides easy scalability and is a cross-platform, document-oriented database. 30 | - MongoDB works on the concept of Collection and Document. 31 | - It combines the ability to scale out with features such as secondary indexes, range queries, sorting, aggregations, and geospatial indexes. 32 | - MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL). 33 | 34 | 35 | MongoDB is a document-based database created in 2007 by 10gen software. It works on the concept of collections and documents. A MongoDB server can contain multiple databases and offers high performance along with redundancy and easy scalability. Collection in MongoDB can be considered as a group of documents that can have different types of fields. The document is a set of key-value pairs having a dynamic schema i.e. common fields may hold different types of data and all documents in the same collection need not have the same structure. If you are new to MongoDB but have worked with RDBMS like SQL before, this small table will help you correlate the terminologies: 36 | 37 | | RDBMS | MongoDB | 38 | | ----------- | ----------- | 39 | | Table | Collection | 40 | | Row | Document | 41 | | Column | Field | 42 | | Table join | Embedded documents | 43 | 44 | --- 45 | 46 | ## Key Components 47 | 48 | 1. **_id**: The _id field represents a unique value in the MongoDB document. The _id field is like the document's primary key. If you create a new document without an _id field, MongoDB will automatically create the field. 49 | 2. **Collection**: This is a grouping of MongoDB documents. A collection is the equivalent of a table which is created in any other RDMS such as Oracle. 50 | 3. **Cursor**: This is a pointer to the result set of a query. Clients can iterate through a cursor to retrieve results. 51 | 4. **Database**: This is a container for collections like in RDMS wherein it is a container for tables. Each database gets its own set of files on the file system. A MongoDB server can store multiple databases. 52 | 5. **Document**: A record in a MongoDB collection is basically called a document. The document, in turn, will consist of field name and values. 53 | 6. **Field**: A name-value pair in a document. A document has zero or more fields. Fields are analogous to columns in relational databases. 54 | 55 | --- 56 | 57 | ## Document 58 | 59 | A Document in MongoDB is an ordered set of keys with associated values. It is represented by a map, hash, or dictionary. In JavaScript, documents are represented as objects: 60 | ```json 61 | {"greeting" : "Hello world!"} 62 | ``` 63 | Complex documents will contain multiple key/value pairs: 64 | ```json 65 | {"greeting" : "Hello world!", "views" : 3} 66 | ``` 67 | 68 | --- 69 | 70 | ## Collection 71 | 72 | A collection in MongoDB is a group of documents. If a document is the MongoDB analog of a row in a relational database, then a collection can be thought of as the analog to a table. 73 | Documents within a single collection can have any number of different "shapes.", i.e. collections have dynamic schemas. 74 | 75 | For example, both documents could be stored in a single collection: 76 | ```json 77 | {"greeting" : "Hello world!", "views": 3} 78 | {"signoff": "Good bye"} 79 | ``` 80 | 81 | --- 82 | 83 | ## Namespace 84 | 85 | MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the collection. The concatenation of the collection name and database name is called a namespace 86 | 87 | 88 | 89 | --- 90 | 91 | ## Databases in MongoDB 92 | 93 | MongoDB groups collections into databases. MongoDB can host several databases, each grouping together collections. 94 | Some reserved database names are as follows: 95 | ``` 96 | admin 97 | local 98 | config 99 | ``` 100 | 101 | --- 102 | 103 | ## Mongo Shell 104 | 105 | It is a JavaScript shell that allows interaction with a MongoDB instance from the command line. With that one can perform administrative functions, inspecting an instance, or exploring MongoDB. 106 | 107 | To start the shell, run the mongo executable: 108 | ```shell 109 | $ mongod 110 | $ mongo 111 | MongoDB shell version: 4.2.0 112 | connecting to: test 113 | > 114 | ``` 115 | 116 | The shell is a full-featured JavaScript interpreter, capable of running arbitrary JavaScript programs. Let’s see how basic math works on this: 117 | ```shell 118 | > x = 100; 119 | 200 120 | > x / 5; 121 | 20 122 | ``` 123 | 124 | --- 125 | 126 | ## Advantages of MongoDB 127 | 128 | Some advantages of MongoDB are as follows: 129 | 130 | - Cross-platform 131 | - Written in C++. 132 | - Secure and scalable 133 | - Schema-less database 134 | - Document-oriented 135 | - Supports high-availability and redundancy 136 | - MongoDB supports field, range-based, string pattern matching type queries. for searching the data in the database 137 | - MongoDB support primary and secondary index on any fields 138 | - MongoDB basically uses JavaScript objects in place of procedures 139 | - MongoDB uses a dynamic database schema 140 | - MongoDB is very easy to scale up or down 141 | - MongoDB has inbuilt support for data partitioning (Sharding). 142 | 143 | 144 | --- 145 | 146 | ## Features of MongoDB 147 | 148 | 149 | Feature | Description | 150 | | ----------- | ----------- | 151 | | Indexing | It indexes are created in order to improve the search performance. | 152 | | Replication | MongoDB distributes the data across different machines. | 153 | | Ad-hoc Queries | It supports ad-hoc queries by indexing the BSON documents & using a unique query language. | 154 | | Schemaless | It is very flexible because of its schema-less database that is written in C++. | 155 | | Sharding | MongoDB uses sharding to enable deployments with very large data sets and high throughput operations. | 156 | 157 | --- 158 | 159 | ## Indexes in MongoDB 160 | 161 | MongoDB supports the types of the index for running a query. 162 | 1. Single Field Index 163 | 2. Compound Index 164 | 3. Multikey Index 165 | 4. Geospatial Index 166 | 5. Text Index 167 | 6. Hashed Index 168 | 169 | 170 | 171 | --- 172 | 173 | ## For more information 174 | 1. [MongoDB Interview Questions and Answers](https://hackr.io/blog/mongodb-interview-questions) 175 | 2. [MongoDB Interview Questions](https://www.interviewbit.com/mongodb-interview-questions/) 176 | 3. [MongoDB Interview Questions For Beginners And Professionals In 2020](https://www.edureka.co/blog/mongodb-interview-questions-for-beginners-and-professionals) -------------------------------------------------------------------------------- /docs/algorithms/queue.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Queue 4 | parent: Data Structures 5 | resource: true 6 | desc: "Queue interview questions and answers." 7 | categories: [Queue] 8 | 9 | --- 10 | 11 | # Queue 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | ## Implement Queue using Stacks 26 | 27 | Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). 28 | 29 | Implement the MyQueue class: 30 | 31 | - void push(int x) Pushes element x to the back of the queue. 32 | - int pop() Removes the element from the front of the queue and returns it. 33 | - int peek() Returns the element at the front of the queue. 34 | - boolean empty() Returns true if the queue is empty, false otherwise. 35 | 36 | **Example 1:** 37 | 38 | Input 39 | 40 | ``` 41 | ["MyQueue", "push", "push", "peek", "pop", "empty"] 42 | [[], [1], [2], [], [], []] 43 | ``` 44 | 45 | Output 46 | 47 | ``` 48 | [null, null, null, 1, 1, false] 49 | ``` 50 | 51 | Explanation 52 | 53 | ``` 54 | MyQueue myQueue = new MyQueue(); 55 | myQueue.push(1); // queue is: [1] 56 | myQueue.push(2); // queue is: [1, 2] (leftmost is front of the queue) 57 | myQueue.peek(); // return 1 58 | myQueue.pop(); // return 1, queue is [2] 59 | myQueue.empty(); // return false 60 | ``` 61 | 62 | ### Solution 1 63 | 64 | I have one input stack, onto which I push the incoming elements, and one output stack, from which I peek/pop. I move elements from input stack to output stack when needed, i.e., when I need to peek/pop but the output stack is empty. When that happens, I move all elements from input to output stack, thereby reversing the order so it's the correct order for peek/pop. 65 | 66 | The loop in peek does the moving from input to output stack. Each element only ever gets moved like that once, though, and only after we already spent time pushing it, so the overall amortized cost for each operation is O(1). 67 | 68 | #### Implementation 69 | 70 | ```java 71 | class MyQueue { 72 | Stack input = new Stack(); 73 | Stack output = new Stack(); 74 | 75 | //Push element x to the back of queue. 76 | public void push(int x) { 77 | input.push(x); 78 | } 79 | 80 | //Removes the element from in front of queue. 81 | public int pop() { 82 | peek(); 83 | return output.pop(); 84 | } 85 | 86 | // Get the front element. 87 | public int peek() { 88 | if (output.empty()) 89 | while (!input.empty()) 90 | output.push(input.pop()); 91 | return output.peek(); 92 | } 93 | 94 | // Return whether the queue is empty. 95 | public boolean empty() { 96 | return input.empty() && output.empty(); 97 | } 98 | 99 | public static void main(String[] args){ 100 | //Your MyQueue object will be instantiated and called as such: 101 | MyQueue obj = new MyQueue(); 102 | obj.push(x); 103 | int param_2 = obj.pop(); 104 | int param_3 = obj.peek(); 105 | boolean param_4 = obj.empty(); 106 | } 107 | } 108 | 109 | ``` 110 | 111 | #### Complexity Analysis 112 | 113 | **Time Complexity**: 114 | 115 | **Space Complexity**: 116 | 117 | 118 | 119 | ### Solution 2 120 | 121 | Keep 2 stacks, let's call them inbox and outbox. 122 | 123 | **Enqueue:** 124 | 125 | Push the new element onto inbox 126 | 127 | **Dequeue:** 128 | 129 | If outbox is empty, refill it by popping each element from inbox and pushing it onto outbox 130 | 131 | Pop and return the top element from outbox 132 | 133 | Using this method, each element will be in each stack exactly once - meaning each element will be pushed twice and popped twice, giving amortized constant time operations. 134 | 135 | #### Implementation 136 | 137 | ```java 138 | public class Queue 139 | { 140 | 141 | private Stack inbox = new Stack(); 142 | private Stack outbox = new Stack(); 143 | 144 | public void queue(E item) { 145 | inbox.push(item); 146 | } 147 | 148 | public E dequeue() { 149 | if (outbox.isEmpty()) { 150 | while (!inbox.isEmpty()) { 151 | outbox.push(inbox.pop()); 152 | } 153 | } 154 | return outbox.pop(); 155 | } 156 | 157 | } 158 | ``` 159 | 160 | 161 | #### Complexity Analysis 162 | 163 | **Time Complexity**: 164 | 165 | **Space Complexity**: 166 | 167 | 168 | ### Solution 3 : One Stack Solution 169 | 170 | You can even simulate a queue using only one stack. The second (temporary) stack can be simulated by the call stack of recursive calls to the insert method. 171 | 172 | The principle stays the same when inserting a new element into the queue: 173 | 174 | - You need to transfer elements from one stack to another temporary stack, to reverse their order. 175 | - Then push the new element to be inserted, onto the temporary stack 176 | - Then transfer the elements back to the original stack 177 | - The new element will be on the bottom of the stack, and the oldest element is on top (first to be popped) 178 | 179 | A Queue class using only one Stack, would be as follows: 180 | 181 | #### Implementation 182 | 183 | ```java 184 | public class SimulatedQueue { 185 | private java.util.Stack stack = new java.util.Stack(); 186 | 187 | public void insert(E elem) { 188 | if (!stack.empty()) { 189 | E topElem = stack.pop(); 190 | insert(elem); 191 | stack.push(topElem); 192 | } 193 | else 194 | stack.push(elem); 195 | } 196 | 197 | public E remove() { 198 | return stack.pop(); 199 | } 200 | } 201 | ``` 202 | ### Solution 4 : Short O(1) amortized 203 | 204 | I have one input stack, onto which I push the incoming elements, and one output stack, from which I peek/pop. I move elements from input stack to output stack when needed, i.e., when I need to peek/pop but the output stack is empty. When that happens, I move all elements from input to output stack, thereby reversing the order so it's the correct order for peek/pop. 205 | 206 | The loop in peek does the moving from input to output stack. Each element only ever gets moved like that once, though, and only after we already spent time pushing it, so the overall amortized cost for each operation is O(1). 207 | 208 | #### Implementation 209 | 210 | ```java 211 | class MyQueue { 212 | 213 | Stack input = new Stack(); 214 | Stack output = new Stack(); 215 | 216 | public void push(int x) { 217 | input.push(x); 218 | } 219 | 220 | public void pop() { 221 | peek(); 222 | output.pop(); 223 | } 224 | 225 | public int peek() { 226 | if (output.empty()) 227 | while (!input.empty()) 228 | output.push(input.pop()); 229 | return output.peek(); 230 | } 231 | 232 | public boolean empty() { 233 | return input.empty() && output.empty(); 234 | } 235 | } 236 | ``` 237 | 238 | --- 239 | 240 | ## More Details: 241 | 1. [How to implement a queue using two stacks?](https://stackoverflow.com/questions/69192/how-to-implement-a-queue-using-two-stacks) -------------------------------------------------------------------------------- /docs/spring/spring-batch.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Spring Batch 4 | parent: Spring 5 | resource: true 6 | desc: "Spring Batch interview questions and answers." 7 | categories: [Spring Batch] 8 | --- 9 | 10 | # Spring Batch 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Introduction to Spring Batch 25 | 26 | Spring Batch provides reusable functions that are essential in processing large volumes of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management. It also provides more advanced technical services and features that will enable extremely high-volume and high performance batch jobs through optimization and partitioning techniques. Simple as well as complex, high-volume batch jobs can leverage the framework in a highly scalable manner to process significant volumes of information. 27 | 28 | ### Features 29 | - Transaction management 30 | - Chunk based processing 31 | - Declarative I/O 32 | - Start/Stop/Restart 33 | - Retry/Skip 34 | - Web based administration interface (Spring Cloud Data Flow) 35 | 36 | 37 | ### spring batch components 38 | 39 | Spring Batch is a framework for batch processing in the Spring framework. It provides reusable functions for processing large volumes of data in batch jobs. The main components of Spring Batch include: 40 | 41 | 1. Job: A job is a batch process that is made up of one or more steps. 42 | 43 | 2. Step: A step is a single unit of work that is executed as part of a job. It can be as simple as reading data from a file and writing it to a database, or as complex as performing multiple tasks in parallel. 44 | 45 | 3. ItemReader: An ItemReader reads data from a source and provides it to the ItemProcessor. 46 | 47 | 4. ItemProcessor: An ItemProcessor processes the data read by the ItemReader and returns the processed data. 48 | 49 | 5. ItemWriter: An ItemWriter writes the processed data to a destination. 50 | 51 | 6. JobRepository: A JobRepository is responsible for maintaining the state of a job and its steps. 52 | 53 | 7. JobLauncher: A JobLauncher is used to launch a job. 54 | 55 | 8. JobExplorer: A JobExplorer allows you to access information about past execution of a job. 56 | 57 | 9. JobRegistry: A JobRegistry is used to register jobs with the batch infrastructure. 58 | 59 | 10. JobParameters: JobParameters are used to pass data to a job at runtime. 60 | 61 | These are the main components of Spring Batch, there are many other components that can be used to customize and extend the functionality of the framework. 62 | 63 | It provides reusable functions that are essential in processing large volumes of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management. 64 | 65 | The architecture of Spring Batch consists of three main components: 66 | 67 | **Job:** A job represents a batch process that is executed. It is composed of one or more steps, and each step contains a reader, a processor, and a writer. 68 | 69 | **Step:** A step is a domain object that represents an independent, sequential phase of a job and contains a reader, a processor, and a writer. 70 | 71 | **Item:** An item represents a single record that is read, processed, and written. Spring Batch provides support for reading and writing items in various formats, including XML, CSV, and database. 72 | 73 | In addition to these components, Spring Batch also provides a JobRepository, which is responsible for maintaining the state of the job and its execution status, and a JobLauncher, which is responsible for starting and stopping the job. 74 | 75 | Spring Batch also provides a number of built-in components, such as readers, processors, and writers for handling common data formats and tasks, as well as an extensible API for building custom components. 76 | 77 | 78 | ### Example of how to use Spring Batch 79 | 80 | Here's an example of how to use Spring Batch with Spring Boot to read data from a CSV file, process it, and then write it to a database: 81 | 82 | 1. First, create a Spring Boot application with the Spring Batch and Spring Data dependencies. 83 | 84 | 2. Create a batch configuration class that sets up the batch job and the necessary steps. 85 | 86 | 87 | 88 | ```java 89 | 90 | import org.springframework.beans.factory.annotation.Autowired; 91 | import org.springframework.context.annotation.Bean; 92 | import org.springframework.context.annotation.Configuration; 93 | import org.springframework.core.io.ClassPathResource; 94 | 95 | @Configuration 96 | public class BatchConfig { 97 | @Autowired 98 | private JobBuilderFactory jobBuilderFactory; 99 | 100 | @Autowired 101 | private StepBuilderFactory stepBuilderFactory; 102 | 103 | @Bean 104 | public Job readCSVFileJob() { 105 | return jobBuilderFactory 106 | .get("readCSVFileJob") 107 | .start(step1()) 108 | .build(); 109 | } 110 | 111 | @Bean 112 | public Step step1() { 113 | return stepBuilderFactory 114 | .get("step1") 115 | .chunk(5) 116 | .reader(reader()) 117 | .processor(processor()) 118 | .writer(writer()) 119 | .build(); 120 | } 121 | 122 | 123 | 124 | @Bean 125 | public PersonItemProcessor processor() { 126 | return new PersonItemProcessor(); 127 | } 128 | 129 | @Bean 130 | public JdbcBatchItemWriter writer() { 131 | JdbcBatchItemWriter writer = new JdbcBatchItemWriter<>(); 132 | writer.setDataSource(dataSource); 133 | writer.setSql("INSERT INTO people (first_name, last_name) VALUES (:firstName, :lastName)"); 134 | writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()); 135 | return writer; 136 | } 137 | 138 | 139 | 140 | } 141 | ``` 142 | 143 | 3. Create a class that represents the data you're reading from the CSV file and a class that handles the processing of the data. 144 | 145 | ```java 146 | public class Person { 147 | private String firstName; 148 | private String lastName; 149 | // getters and setters 150 | } 151 | 152 | public class PersonItemProcessor implements ItemProcessor { 153 | @Override 154 | public Person process(final Person person) throws Exception { 155 | final String firstName = person.getFirstName().toUpperCase(); 156 | final String lastName = person.getLastName().toUpperCase(); 157 | 158 | final Person transformedPerson = new Person(firstName, lastName); 159 | return transformedPerson; 160 | } 161 | } 162 | 163 | 164 | ``` 165 | 166 | 4. Finally, run the job by creating a `CommandLineRunner` that calls the `jobLauncher.run()` method and passing in the job name as a parameter. 167 | 168 | 169 | ```java 170 | 171 | @SpringBootApplication 172 | public class Application implements CommandLineRunner { 173 | @Autowired 174 | JobLauncher jobLauncher; 175 | @Autowired 176 | Job job; 177 | public static void main(String[] args) { 178 | SpringApplication.run(Application.class, args); 179 | } 180 | @Override 181 | public void run(String... args) throws Exception { 182 | JobExecution execution = jobLauncher.run(job, new JobParameters()); 183 | System.out.println("Job Exit Status : "+ execution.getStatus()); 184 | } 185 | } 186 | 187 | 188 | ``` 189 | 190 | This is a basic example of how Spring Batch and Spring Boot can be used to perform batch processing. I 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /docs/database/hibernate.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Hibernate 4 | parent: Database 5 | resource: true 6 | desc: "Hibernate interview questions and answers." 7 | categories: [Hibernate] 8 | --- 9 | 10 | # Hibernate 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | 25 | Hibernate is an Object Relational Mapping tool (ORM tool), that maps the Java objects to the database tables and vice-versa. 26 | 27 | Some points to remember: 28 | - Hibernate framework provides the facility to create database tables automatically 29 | - Hibernate framework provides us object-oriented version of SQL known as HQL (Hibernate Query Language). It generates the database independent queries. So, even if our database gets changed, we don’t have to change our SQL queries according to the new database 30 | - Using Hibernate, we can define relationships between our Entities (tables), that makes it easy to fetch data from multiple tables 31 | - Hibernate supports Caching, that improves the performance of our application 32 | - Using Hibernate, we can generate the Primary key of our tables automatically 33 | 34 | 35 | 36 | --- 37 | 38 | ## JPA vs Hibernate 39 | JPA is just a specification i.e. it defines a set of concepts that can be implemented by any tool or framework, and Hibernate is one of the implementation of JPA. 40 | 41 | 42 | 43 | --- 44 | 45 | ## @Entity annotation 46 | 47 | @Entity annotation defines that a class can be mapped to a database table. The class fields will be mapped to the columns of the table. 48 | 49 | 50 | 51 | --- 52 | 53 | ## @Id & @GeneratedValue 54 | 55 | @Id annotation defines the primary key of a table and @GeneratedValue annotation is used to specify the primary key generation strategy to use. If the strategy is not specified, the default strategy AUTO will be used. 56 | 57 | 58 | --- 59 | 60 | ## get() and load() methods of Hibernate Session 61 | 62 | 63 | Hibernate Session class provides two methods to access object, session.get() and session.load() 64 | 65 | The differences are: 66 | - get() method involves a database hit, if the object does not exist in Session cache and it returns a fully initialized object which may involve several database calls, whereas load() method returns a proxy object and it only hit the database if any method other than getId() is called on the entity object 67 | - load() method results in slightly better performance as it can return a proxy object, it will only hit the database when a non-identifier getter method is called, whereas get() method returns a fully initialized object when it does not exist in Session cache which may involve multiple database calls based on entity relationships 68 | - get() method returns null if the object is not found in the cache as well as the database whereas load() method will throw ObjectNotFoundException but never return null 69 | - If you are not sure whether the object exists or not, then use get() as it will return null but if you are sure that the object exists, then use load() method as it is lazily initialized 70 | 71 | 72 | 73 | --- 74 | 75 | ## save(), saveOrUpdate() and persist() method of Hibernate Session 76 | 77 | Hibernate Session class provides various methods to save an object into the database, like save(), saveOrUpdate() and persist() 78 | 79 | The difference between save() and saveOrUpdate() method is that save() method saves the record into the database by INSERT query, generates a new identifier and returns the Serializable identifier back, while saveOrUpdate() method either INSERT the record or UPDATE the record if it already exists, so it involves extra processing to find whether the record already exists in the table or not. 80 | Similar to save(), persist() method is also used to save the record into the database table. 81 | 82 | The differences between save() and persist() are: 83 | 84 | - Return type of persist() method is void while return type of save() method is Serializable object 85 | - Both persist() and save() methods makes a transient instance persistent. But persist() method does not guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time 86 | - Both behave differently when they are executed outside the transaction boundaries. persist() method ensures that it will not execute an INSERT when it is called outside of a transaction boundary whereas save() method does not guarantee this, it returns an identifier and if an INSERT query has to be executed to get the identifier then this INSERT happens immediately and it does not matter if the save() is called inside or outside of a transaction 87 | - persist() method is useful in long-running conversation with an extended Session context because it does not execute an INSERT outside of a transaction. On the other hand, save() method is not good in a long-running conversation with an extended Session context 88 | 89 | 90 | 91 | --- 92 | 93 | ## Session and SessionFactory 94 | 95 | SessionFactory creates and manages the Session objects. 96 | 97 | **Some points about SessionFactory:** 98 | - it is one instance per datasource/database 99 | - it is thread-safe 100 | - it is an immutable and heavy-weight object as it maintains Sessions, mappings, hibernate configurations etc. 101 | - SessionFactory provides second level cache in hibernate also called application-level cache 102 | 103 | **Some points about Session:** 104 | - Session objects are created using sessionFactory.openSession() 105 | - It is one instance per client/thread/transaction 106 | - It is not thread-safe 107 | - It is light-weight 108 | - Session provides first level cache, which is short-lived 109 | 110 | 111 | --- 112 | 113 | ## First Level and Second Level Cache 114 | 115 | Hibernate framework provides caching at two levels, first-level cache which is at the Session level and second-level cache which is at the application level. 116 | 117 | **The first level cache** minimizes the database access for the same object if it is requested from the same Session. The first level cache is by default enabled. When you call session.get() method then it hits the database, and while returning, it also saves this object in the first-level cache. So, the subsequent requests for this same object from the same session will not hit the database and the object from cache will be used. 118 | 119 | But, since this cache is associated with the Session object, which is a short-lived object in Hibernate, as soon as the session is closed, all the information held in the cache is also lost. So, if we try to load the same object using the get() method, Hibernate will go to the database again and fetch the record. 120 | 121 | This poses a significant performance challenge in an application where multiple sessions are used, Hibernate provides second-level cache for this and it can be shared among multiple sessions. 122 | 123 | **The second level cache** is maintained at the SessionFactory level, this cache is by default disabled, to enable second level cache in hibernate, it needs to be configured in hibernate configuration file, i.e. hibernate.cfg.xml file. There are various providers of second level cache, like EhCache, OSCache etc. 124 | 125 | Once second level cache is configured, then object request will first go to the first-level cache, if it is not found there, then it will look for this object in second-level cache, if found then it will be returned from the second-level cache and it will also save a copy in first-level cache. 126 | 127 | But, If the object is not found in the second-level cache also, then it will hit the database and if it present in database, this object will be put into both first and second level cache, so that if any other session requests for this object then it will be returned from the cache. 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /docs/misc/http.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: HTTP methods 4 | parent: Misc 5 | resource: true 6 | desc: "HTTP methods overview interview questions and answers." 7 | categories: [HTTP methods overview] 8 | --- 9 | 10 | # HTTP methods overview 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | 25 | 26 | | Method | Scope | Semantics | Idempotent | Safe | 27 | |-----------------|---------------|------------|------------|-----| 28 | | GET | collection | Retrieve all resources in a collection| Yes | Yes | 29 | | GET | collection | Retrieve a single resource | Yes |Yes| 30 | | HEAD | collection | Retrieve all resources in a collection (header only) | Yes |Yes | 31 | | HEAD | resource | Retrieve a single resource (header only) | Yes | Yes| 32 | | POST | collection | Create a new resource in a collection | No | No | 33 | | PUT | resource | Update a resource |Yes | No | 34 | | PATCH | resource | Update a resource | No | No | 35 | | DELETE | resource | Delete a resource |Yes | No | 36 | | OPTIONS | any | Return available HTTP methods and other options | Yes | Yes | 37 | 38 | 39 | 40 | 41 | --- 42 | 43 | ## Idempotency in HTTP 44 | 45 | Idempotency is a property of HTTP methods. 46 | 47 | A request method is considered "idempotent" if the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request. Of the request methods defined by this specification, PUT, DELETE, and safe request methods are idempotent. 48 | 49 | Like the definition of safe, the idempotent property only applies to what has been requested by the user; a server is free to log each request separately, retain a revision control history, or implement other non-idempotent side effects for each idempotent request. 50 | 51 | > The term idempotent is used more comprehensively to describe an operation that will produce the same results if executed once or multiple times [...] An idempotent function is one that has the property f(f(x)) = f(x) for any value x. 52 | 53 | 54 | Ref: [4.2.2. Idempotent Methods](https://www.rfc-editor.org/rfc/rfc7231#section-4.2.2) 55 | 56 | 57 | --- 58 | 59 | ## Safe Methods 60 | 61 | Request methods are considered "safe" if their defined semantics are essentially read-only; i.e., the client does not request, and does not expect, any state change on the origin server as a result of applying a safe method to a target resource. 62 | 63 | This definition of safe methods does not prevent an implementation from including behavior that is potentially harmful, that is not entirely read-only, or that causes side effects while invoking a safe method. What is important, however, is that the client did not request that additional behavior and cannot be held accountable for it. 64 | 65 | Of the request methods defined by this specification, the GET, HEAD, OPTIONS, and TRACE methods are defined to be safe 66 | 67 | Ref: [4.2.1. Safe Methods](https://www.rfc-editor.org/rfc/rfc7231#section-4.2.1) 68 | 69 | Ref: https://stackoverflow.com/questions/45016234/what-is-idempotency-in-http-methods 70 | 71 | 72 | 73 | --- 74 | 75 | ## Why DELETE method is defined as idempotent 76 | 77 | Consider a client performs a `DELETE` request to delete a resource from the server. The server processes the request, the resource gets deleted and the server returns 204. Then the client repeats the same `DELETE` request and, as the resource has already been deleted, the server returns `404`. 78 | 79 | Despite the different status code received by the client, the effect produced by a single `DELETE` request is the same effect of multiple `DELETE` requests to the same URI. 80 | 81 | Finally, requests with idempotent methods can be repeated automatically if a communication failure occurs before the client is able to read the server's response. The client knows that repeating the request will have the same intended effect, even if the original request succeeded, though the response might be different. 82 | 83 | 84 | --- 85 | 86 | ## Why PATCH method is not idempotent 87 | 88 | PATCH method, which is neither safe nor idempotent. However, to prevent collisions, PATCH requests can be issued such a way as to be idempotent, as quoted below: 89 | 90 | A PATCH request can be issued in such a way as to be idempotent, which also helps prevent bad outcomes from collisions between two PATCH requests on the same resource in a similar time frame. Collisions from multiple PATCH requests may be more dangerous than PUT collisions because some patch formats need to operate from a known base-point or else they will corrupt the resource. Clients using this kind of patch application SHOULD use a conditional request such that the request will fail if the resource has been updated since the client last accessed the resource. For example, the client can use a strong ETag in an If-Match header on the PATCH request. 91 | 92 | 93 | 94 | --- 95 | 96 | ## When to Use Put and When Patch 97 | 98 | When a client needs to replace an existing Resource entirely, they can use PUT. When they're doing a partial update, they can use HTTP PATCH. 99 | 100 | For instance, when updating a single field of the Resource, sending the complete Resource representation can be cumbersome and uses a lot of unnecessary bandwidth. In such cases, the semantics of PATCH make a lot more sense. 101 | 102 | Another important aspect to consider here is idempotence. PUT is idempotent; PATCH can be idempotent but isn't required to be. So, depending on the semantics of the operation we're implementing, we can also choose one or the other based on this characteristic. 103 | 104 | 105 | Ref: https://www.baeldung.com/http-put-patch-difference-spring 106 | 107 | 108 | --- 109 | 110 | ## Why is PUT idempotent? 111 | 112 | In RFC 2616 citation, PUT is considered idempotent. When you PUT a resource, these two assumptions are in play: 113 | 114 | 1. You are referring to an entity, not to a collection. 115 | 2. The entity you are supplying is complete (the entire entity). 116 | 117 | Let's look at one of your examples. 118 | 119 | ```json 120 | { "username": "skwee357", "email": "skwee357@domain.com" } 121 | ``` 122 | 123 | If you POST this document to `/users`, as you suggest, then you might get back an entity such as 124 | 125 | ```json 126 | ## /users/1 127 | 128 | { 129 | "username": "skwee357", 130 | "email": "skwee357@domain.com" 131 | } 132 | ``` 133 | 134 | If you want to modify this entity later, you choose between PUT and PATCH. A `PUT` might look like this: 135 | ```json 136 | PUT /users/1 137 | { 138 | "username": "skwee357", 139 | "email": "skwee357@gmail.com" // new email address 140 | } 141 | ``` 142 | You can accomplish the same using `PATCH`. That might look like this: 143 | 144 | 145 | ```json 146 | PATCH /users/1 147 | { 148 | "email": "skwee357@gmail.com" // new email address 149 | } 150 | 151 | ``` 152 | Here The `PUT` included all of the parameters on this user, but `PATCH` only included the one that was being modified (email). 153 | 154 | When using PUT, it is assumed that you are sending the complete entity, and that complete entity replaces any existing entity at that URI. In the above example, the PUT and PATCH accomplish the same goal: they both change this user's email address. But PUT handles it by replacing the entire entity, while PATCH only updates the fields that were supplied, leaving the others alone. 155 | 156 | Since PUT requests include the entire entity, if you issue the same request repeatedly, it should always have the same outcome (the data you sent is now the entire data of the entity). Therefore PUT is idempotent. 157 | 158 | Ref: https://stackoverflow.com/questions/28459418/use-of-put-vs-patch-methods-in-rest-api-real-life-scenarios 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /docs/misc/production.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Production 4 | parent: Misc 5 | resource: true 6 | desc: "Production interview questions and answers." 7 | categories: [Production] 8 | --- 9 | 10 | # Production 11 | {: .no_toc } 12 | 13 |
    14 | 15 | Table of contents 16 | 17 | {: .text-delta } 18 | 1. TOC 19 | {:toc} 20 |
    21 | 22 | --- 23 | 24 | ## Production support tools 25 | 26 | 27 | Production support tools for microservices are used to monitor, troubleshoot, and maintain microservices-based applications in a production environment. Here are a few examples of production support tools for microservices: 28 | 29 | ### Kubernetes 30 | 31 | Kubernetes is an open-source container orchestration platform that can be used to deploy and manage microservices. It provides features such as automatic scaling, self-healing, and rolling updates, which can make it easier to maintain microservices in a production environment. 32 | 33 | ### Prometheus 34 | 35 | Prometheus is an open-source monitoring tool that can be used to monitor the performance of microservices. It provides features such as time-series data collection, alerting, and visualizations that can help identify and troubleshoot performance issues. 36 | 37 | ### ELK Stack 38 | 39 | ELK stands for Elasticsearch, Logstash, and Kibana. It is a collection of open-source tools that can be used to collect, store, and analyze log data from microservices. This can help identify issues and troubleshoot problems. 40 | 41 | ### Zipkin 42 | 43 | Zipkin is an open-source distributed tracing system that can be used to trace requests and responses between microservices. It can help identify and troubleshoot issues with service-to-service communication. 44 | 45 | ### Istio 46 | 47 | Istio is an open-source service mesh that can be used to manage service-to-service communication in a microservices environment. It provides features such as traffic management, service discovery, and security that can help maintain microservices in production. 48 | 49 | ### Chaos Engineering 50 | 51 | Chaos engineering is a practice of intentionally introducing controlled failures and disruptions to a system to identify weaknesses and improve resilience. Tools like Gremlin, Netflix's Chaos Monkey are used to test and improve the system's ability to handle failures and errors. 52 | 53 | ### Microservices API Management 54 | 55 | API management platforms like Apigee, Kong, Tyk, etc. can be used to handle the API calls, security, and rate-limiting. 56 | 57 | ### Monitoring and alerting tools 58 | 59 | like Datadog, New Relic, and Grafana can be used to monitor the health and performance of microservices. These tools can provide real-time visibility into resource usage, response times, and errors, which can help identify and troubleshoot issues. 60 | 61 | ### Service meshes 62 | 63 | such as Linkerd and Consul Connect can help with service discovery, traffic management, and security in a microservices environment. They provide features like load balancing, service-to-service authentication and authorization, and traffic routing. 64 | 65 | ### Distributed tracing tools 66 | 67 | like Jaeger and OpenTracing can help to trace the flow of requests and responses between microservices. This can help identify and troubleshoot issues with service-to-service communication and provide insight into the overall performance of the system. 68 | 69 | ### Configuration management tools 70 | 71 | like Consul, etcd, and ZooKeeper can be used to store and manage configuration data for microservices. This can help to ensure that microservices are running with the correct configuration in different environments. 72 | 73 | ### CI/CD tools 74 | 75 | like Jenkins, CircleCI, and TravisCI can be used to automate the build, test, and deployment of microservices. This can help to ensure that microservices are deployed and running correctly in different environments. 76 | 77 | ### Incident Management and IT Service Management (ITSM) platforms 78 | 79 | like PagerDuty, Jira Service Desk, and ServiceNow can be used to manage and track incidents, service requests, and changes related to microservices. These tools can help to ensure that incidents are handled in a timely and efficient manner and that changes to the microservices are properly tracked and managed. 80 | 81 | ### Backup and recovery tools 82 | 83 | like Veeam, Commvault, and Veritas can be used to backup and recover microservices and their data. These tools can help ensure that microservices and their data are protected in case of a disaster or other unexpected event. 84 | 85 | ### A/B testing and canary release tools 86 | 87 | like Spinnaker, Jenkins X and GitLab can be used to test new features and releases of microservices before they are rolled out to production. These tools can help to minimize the risk of introducing new features and releases and can help to ensure that new features and releases are working correctly before they are made available to users. 88 | 89 | 90 | In conclusion, there are many production support tools available for microservices, and the best choice will depend on the specific requirements of the application and the environment it is running in. It's important to use a combination of different tools to provide a comprehensive production support solution for microservices. 91 | 92 | 93 | --- 94 | 95 | ## Production issues 96 | 97 | Handling production issues and debugging and fixing them can be a complex process. Here are a few general steps that can be taken to handle production issues and debug and fix them: 98 | 99 | ### Identify the issue 100 | 101 | The first step is to identify the issue. This can be done by reviewing error logs, monitoring data, and gathering information from users. It's important to gather as much information as possible about the issue to help identify the root cause. 102 | 103 | ### Reproduce the issue 104 | 105 | Once the issue has been identified, it's important to reproduce the issue in a controlled environment. This can be done by setting up a test environment that closely mimics the production environment. By reproducing the issue in a controlled environment, it's possible to debug the issue and gather more information about the root cause. 106 | 107 | ### Gather data 108 | 109 | Gather data from various sources like application logs, metrics, and traces to understand the issue better. This data can help to identify the root cause of the issue and can also help to identify any patterns or trends that may be contributing to the issue. 110 | 111 | ### Analyze the data 112 | 113 | Analyze the data to identify the root cause of the issue. This can be done by reviewing error logs, monitoring data, and analyzing performance metrics. 114 | 115 | ### Implement a solution 116 | 117 | Once the root cause of the issue has been identified, implement a solution to fix the issue. This can be done by making changes to the application, updating the infrastructure, or making changes to the environment. 118 | 119 | ### Test the solution 120 | 121 | Test the solution to ensure that it fixes the issue and does not introduce any new issues. This can be done by running tests in a controlled environment or by monitoring the application in production. 122 | 123 | ### Deploy the solution 124 | 125 | Deploy the solution to production. This can be done by rolling out the solution to a small group of users first and then to the entire user base. 126 | 127 | ### Monitor and maintain 128 | 129 | Monitor the application in production to ensure that the issue has been resolved and that the solution is working correctly. This can be done by reviewing error logs, monitoring data, and analyzing performance metrics. 130 | 131 | It's important to have a clear understanding of the requirements of the application, as well as the expected usage patterns, to effectively troubleshoot and fix production issues. It's also important to have a well-defined incident management process in place to handle production issues in an organized and efficient manner. 132 | 133 | 134 | 135 | 136 | --- 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /docs/nodejs/Nodejs.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Nodejs 4 | nav_order: 2 5 | permalink: docs/nodejs 6 | resource: true 7 | desc: "Kafka interview questions and answers." 8 | categories: [Nodejs] 9 | --- 10 | 11 | # Nodejs 12 | {: .no_toc } 13 | 14 |
    15 | 16 | Table of contents 17 | 18 | {: .text-delta } 19 | 1. TOC 20 | {:toc} 21 |
    22 | 23 | --- 24 | 25 | ## Nodejs 26 | 27 | Node.js is an open-source server side runtime environment built on Chrome's V8 JavaScript engine. It provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building highly scalable server-side applications using JavaScript. 28 | 29 | 30 | ### Node.js Process Model 31 | Node.js runs in a single process and the application code runs in a single thread and thereby needs less resources than other platforms. 32 | 33 | All the user requests to your web application will be handled by a single thread and all the I/O work or long running job is performed asynchronously for a particular request. So, this single thread doesn't have to wait for the request to complete and is free to handle the next request. When asynchronous I/O work completes then it processes the request further and sends the response. 34 | 35 | 36 | ### features of Node.js 37 | 38 | **Asynchronous and Event driven** – All APIs of Node.js are asynchronous. This feature means that if a Node receives a request for some Input/Output operation, it will execute that operation in the background and continue with the processing of other requests. Thus it will not wait for the response from the previous requests. 39 | 40 | **Fast in Code execution** – Node.js uses the V8 JavaScript Runtime engine, the one which is used by Google Chrome. Node has a wrapper over the JavaScript engine which makes the runtime engine much faster and hence processing of requests within Node.js also become faster. 41 | 42 | **Single Threaded but Highly Scalable** – Node.js uses a single thread model for event looping. The response from these events may or may not reach the server immediately. However, this does not block other operations. Thus making Node.js highly scalable. Traditional servers create limited threads to handle requests while Node.js creates a single thread that provides service to much larger numbers of such requests. 43 | 44 | **Node.js library uses JavaScript** – This is another important aspect of Node.js from the developer's point of view. The majority of developers are already well-versed in JavaScript. Hence, development in Node.js becomes easier for a developer who knows JavaScript. 45 | 46 | There is an Active and vibrant community for the Node.js framework – The active community always keeps the framework updated with the latest trends in the web development. 47 | 48 | **No Buffering** – Node.js applications never buffer any data. They simply output the data in chunks. 49 | 50 | 51 | ### How does Node.js work? 52 | 53 | A Node.js application creates a single thread on its invocation. Whenever Node.js receives a request, it first completes its processing before moving on to the next request. 54 | 55 | Node.js works asynchronously by using the event loop and callback functions, to handle multiple requests coming in parallel. An Event Loop is a functionality which handles and processes all your external events and just converts them to a callback function. It invokes all the event handlers at a proper time. Thus, lots of work is done on the back-end, while processing a single request, so that the new incoming request doesn't have to wait if the processing is not complete. 56 | 57 | 58 | 59 | 60 | 61 | While processing a request, Node.js attaches a callback function to it and moves it to the back-end. Now, whenever its response is ready, an event is called which triggers the associated callback function to send this response. 62 | 63 | 64 | ### modules of Node.js 65 | 66 | - EventEmitter 67 | - Stream 68 | - FS 69 | - Net 70 | - Global Objects 71 | 72 | ### Asynchronous API 73 | 74 | All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call. 75 | 76 | ### Is Node a single threaded application 77 | 78 | Yes! Node uses a single threaded model with event looping. 79 | 80 | ### Callback 81 | 82 | Callback is an asynchronous equivalent for a function. A callback function is called at the completion of a given task. Node makes heavy use of callbacks. All APIs of Node are written is such a way that they supports callbacks. 83 | 84 | For example, a function to read a file may start reading file and return the control to execution environment immediately so that next instruction can be executed. Once file I/O is complete, it will call the callback function while passing the callback function, the content of the file as parameter. So there is no blocking or wait for File I/O. 85 | 86 | This makes Node.js highly scalable, as it can process high number of request without waiting for any function to return result. 87 | 88 | ### Callback Hell 89 | 90 | The asynchronous function requires callbacks as a return parameter. When multiple asynchronous functions are chained together then callback hell situation comes up. 91 | 92 | --- 93 | 94 | ## Event Listeners 95 | 96 | Event Listeners are similar to call back functions but are associated with some event. For example when a server listens to http request on a given port a event will be generated and to specify http server has received and will invoke corresponding event listener. Basically, Event listener's are also call backs for a corresponding event. 97 | 98 | Node.js has built in event's and built in event listeners. Node.js also provides functionality to create Custom events and Custom Event listeners. 99 | 100 | --- 101 | 102 | ## If Node.js is single threaded then how it handles concurrency? 103 | 104 | Node provides a single thread to programmers so that code can be written easily and without bottleneck. Node internally uses multiple POSIX threads for various I/O operations such as File, DNS, Network calls etc. 105 | 106 | When Node gets I/O request it creates or uses a thread to perform that I/O operation and once the operation is done, it pushes the result to the event queue. On each such event, event loop runs and checks the queue and if the execution stack of Node is empty then it adds the queue result to execution stack. 107 | 108 | This is how Node manages concurrency 109 | 110 | --- 111 | 112 | ## Event Loop 113 | 114 | Node.js is a single threaded application but it support concurrency via concept of event and callbacks. As every API of Node js are asynchronous and being a single thread, it uses async function calls to maintain the concurrency. Node uses observer pattern. Node thread keeps an event loop and whenever any task get completed, it fires the corresponding event which signals the event listener function to get executed. 115 | 116 | The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. 117 | 118 | 119 | 120 | 121 | 122 | Every I/O requires a callback - once they are done they are pushed onto the event loop for execution. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback may be added to the poll queue to eventually be executed. 123 | 124 | --- 125 | 126 | ## Event Emmitter 127 | 128 | All objects that emit events are members of EventEmitter class. These objects expose an eventEmitter.on() function that allows one or more functions to be attached to named events emitted by the object. 129 | 130 | When the EventEmitter object emits an event, all of the functions attached to that specific event are called synchronously. 131 | 132 | ```javascript 133 | const EventEmitter = require('events'); 134 | 135 | class MyEmitter extends EventEmitter {} 136 | 137 | const myEmitter = new MyEmitter(); 138 | myEmitter.on('event', () => { 139 | console.log('an event occurred!'); 140 | }); 141 | myEmitter.emit('event'); 142 | 143 | ``` 144 | 145 | 146 | 147 | --------------------------------------------------------------------------------