thoughtSpace
TwitterGithubRSS Feed

Note Space

Hints, cheat sheets and notes on code.

Definitions

React

React is a JavaScript library for building user interfaces

p value

Given the null hypothesis is true, a p-value is the probability of getting a result as or more extreme than the sample result by random chance alone. If a p-value is lower than our significance level, we reject the null hypothesis. If not, we fail to reject the null hypothesis.

callback

a function passed as an argument to another function or a function that is to be executed after another function has finished executing. A callback is a function passed to another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

GraphQL

an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

Express

a back end web application framework for Node.js.

MongoDB

a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.

NoSql

NoSQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases commonly used for Big data and real-time web apps.

  • SQL databases are relational, NoSQL are non-relational.
  • SQL databases use structured query language and have a predefined schema. NoSQL databases have dynamic schemas for unstructured data.
  • SQL databases are table based, while NoSQL databases are document, key-value, graph or wide-column stores.

This technique allows a function to call another function

function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}

function myCalculator(num1, num2) {
  let sum = num1 + num2;
  return sum;
}

let result = myCalculator(5, 5);
myDisplayer(result);

Testing

Unit Tests - tests the code itself without code

Integration Tests - test code as it interacts with an external service or even a different part of the same project

Regression Tests - tests that verify that some change being made doesn't break the existing system

End to end (e22) tests, full tests of a project (both front and back end)

Production tests, ensuring features work exactly as expected once in production

Mocha is a JavaScript test framework that runs on Node. js and also on the server and allows asynchronous testing along with the use of any assertion library. It tests coverage reports. The next testing tool we are going to talk about is Chai, which is a TDD assertion library for NodeJS and the browser.

Jest is a JavaScript testing framework maintained by Meta, designed and built by Christoph Nakazawa with a focus on simplicity and support for large web applications. It works with projects using Babel, TypeScript, Node.js, React, Angular, Vue.js and Svelte.

Preprocessed CSS

A CSS pre-processor is CSS with added features like nesting and variables. The browser cannot read this, so when the project is built, Node will compile all of your SCSS or LESS code to traditional CSS.

Redux.

A single source of truth for all the data in a javascript application that helps developers implement complex state management at scale. The store object registers any reducers defined elsewhere in the code. Provider makes its data accessible to the entire component tree. Slices represent some data in the store and should have a unique name and initial state. It should also contain a collection of reducers which are functions that take the old state and an action then define the logic required to change the state. useSelector can be used to select any reactive value or slice in the store. useDispatch is used to dispatch an action to the store that changes an app's data.

Test driven development.

Write tests before developing code to implement tasks.

DELETE CASCADE

Specifies that the child data gets deleted when the parent data is deleted. Equivalent to onDelete('cascade') in laravel

UPDATE CASCADE

Specifies that the child data gets updated when the parent data is updated. Equivalent to onUpdate('cascade') in laravel

Service Oriented Architecture(S0A)

Service-Oriented Architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. Its principles are independent of vendors and other technologies.

Microservices

Microservices, also known as Microservice Architecture, is an “architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.”

Terraform

A tool that can help you with building, changing, and also versioning of infrastructure, then there is no better platform than terraform.

Prisma

An open source next-generation ORM that consists of the following parts: Prisma Client: Auto-generated and type-safe query builder for Node.js & TypeScript Prisma Migrate: Migration system Prisma Studio: GUI to view and edit data in your database

Bookshelf JS

Bookshelf is a JavaScript ORM for Node.js, built on the Knex SQL query builder. It features both Promise-based and traditional callback interfaces, transaction support, eager/nested-eager relation loading, polymorphic associations, and support for one-to-one, one-to-many, and many-to-many relations.

Knex

Knex is a technique that is used to build queries. It supports various databases like Postgres, MySQL, SQLite, Oracle, and some others as well. It provides both callbacks and promise interface. It provides connection pooling and standardized responses.

DevOps

DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity: evolving and improving products at a faster pace than organizations using traditional software development and infrastructure management processes.

CI/CD

A method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment

Babel

A free and open-source JavaScript transcompiler that is mainly used to convert ECMAScript 2015+ code into backwards-compatible JavaScript code that can be run by older JavaScript engines. It compiles JSX into React.createElement API calls.

Webpack

A popular module bundling system built on top of Node. js. It can handle not only combination and minification of JavaScript and CSS files, but also other assets. It's a static module bundler for JavaScript applications — it takes all the code from your application and makes it usable in a web browser. Modules are reusable chunks of code built from your app's JavaScript, node_modules, images, and the CSS styles which are packaged to be easily used in your website.

npm

Package manager or a registry containing many code packcages.

Gang Of Four design patterns

Creational Patterns for the creation of objects; Structural Patterns to provide relationship between objects; and finally, Behavioral Patterns to help define how objects interact.

Blockchain

Blockchain is a digital record of transactions distributed and shared among the nodes of a computer network. Each transaction in the blockchain is called a block, and links to another with cryptography techniques. Blockchains are helpful when you are trying to build a decentralized system that ensures the security and integrity of data while maintaining trust between every system user.

Solana

Solana is a decentralized blockchain built to enable scalable, user-friendly apps for the world.

Solidity

An object-oriented programming language for implementing smart contracts on various blockchain platforms, most notably, Ethereum.

Docker

Docker is an open source containerization platform. It enables developers to package applications into containers—standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment. Enables you to separate your applications from your infrastructure so you can deliver software quickly. Helps in CI/CD.

Kubernetes

Docker is a container runtime, Kubernetes is a platform for running and managing containers from many container runtimes. Is used for bundling and managing clusters of containerized applications.

Jenkins

An open source automation server which enables developers around the world to reliably build, test, and deploy their software.

CircleCI

CircleCI is a continuous integration and continuous delivery platform that can be used to implement DevOps practices. Used for building, testing, and deploying a project, by using automation. This automation takes place in pipelines with jobs.

Solid Principles in OOP

  • The SOLID Principles are five principles of Object-Oriented class design. They are a set of rules and best practices to follow while designing a class structure. These five principles help us understand the need for certain design patterns and software architecture in general.
  • The Single Responsibility Principle - the Single Responsibility Principle states that a class should do one thing and therefore it should have only a single reason to change.
  • The Open-Closed Principle - the Open-Closed Principle requires that classes should be open for extension and closed to modification.
  • The Liskov Substitution Principle - the Liskov Substitution Principle states that subclasses should be substitutable for their base classes.
  • The Interface Segregation Principle - segregation means keeping things separated, and the Interface Segregation Principle is about separating the interfaces.
  • The Dependency Inversion Principle - the Dependency Inversion principle states that our classes should depend upon interfaces or abstract classes instead of concrete classes and functions.

Vertical Scaling

Vertical scaling refers to adding more resources (CPU/RAM/DISK) to your server (database or application server is still remains one) as on demand. Vertical Scaling is most commonly used in applications and products of middle-range as well as small and middle-sized companies.

Horizontal Scaling

Horizontal scaling (aka scaling out) refers to adding additional nodes or machines to your infrastructure to cope with new demands.

CORS

𝗖𝗢𝗥𝗦 𝘀𝘁𝗮𝗻𝗱𝘀 𝗳𝗼𝗿 𝗖𝗿𝗼𝘀𝘀-𝗢𝗿𝗶𝗴𝗶𝗻 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲 𝗦𝗵𝗮𝗿𝗶𝗻𝗴

𝘐𝘵'𝘴 𝘢 𝘸𝘢𝘺 𝘧𝘰𝘳 𝘣𝘳𝘰𝘸𝘴𝘦𝘳𝘴 𝘵𝘰 𝘥𝘦𝘵𝘦𝘳𝘮𝘪𝘯𝘦 𝘸𝘩𝘦𝘵𝘩𝘦𝘳 𝘰𝘳 𝘯𝘰𝘵 𝘵𝘩𝘦𝘺 𝘴𝘩𝘰𝘶𝘭𝘥 𝘢𝘭𝘭𝘰𝘸 𝘳𝘦𝘲𝘶𝘦𝘴𝘵𝘴 𝘧𝘳𝘰𝘮 𝘰𝘯𝘦 𝘥𝘰𝘮𝘢𝘪𝘯 𝘵𝘰 𝘢𝘤𝘤𝘦𝘴𝘴 𝘳𝘦𝘴𝘰𝘶𝘳𝘤𝘦𝘴 𝘧𝘳𝘰𝘮 𝘢𝘯𝘰𝘵𝘩𝘦𝘳 𝘥𝘰𝘮𝘢𝘪𝘯. 𝘐𝘵'𝘴 𝘶𝘴𝘦𝘥 𝘸𝘩𝘦𝘯 𝘺𝘰𝘶 𝘸𝘢𝘯𝘵 𝘵𝘰 𝘦𝘮𝘣𝘦𝘥 𝘤𝘰𝘯𝘵𝘦𝘯𝘵 𝘧𝘳𝘰𝘮 𝘰𝘯𝘦 𝘴𝘪𝘵𝘦 𝘪𝘯𝘵𝘰 𝘢𝘯𝘰𝘵𝘩𝘦𝘳 𝘴𝘪𝘵𝘦.

𝗧𝗵𝗲𝗿𝗲 𝗮𝗿𝗲 𝘁𝘄𝗼 𝘁𝘆𝗽𝗲𝘀 𝗼𝗳 𝗖𝗢𝗥𝗦 𝗵𝗲𝗮𝗱𝗲𝗿𝘀: ① Access-Control-Allow-Origin ② Access-Control-Allow-Methods

👀 𝗧𝗵𝗲 𝗳𝗶𝗿𝘀𝘁 𝗵𝗲𝗮𝗱𝗲𝗿 tells the browser which domains are allowed to access the requested resource.

👀 𝗧𝗵𝗲 𝘀𝗲𝗰𝗼𝗻𝗱 𝗵𝗲𝗮𝗱𝗲𝗿 tell the browser which methods (e.g., GET, POST ) are allowed.

CSRF

CSRF stands for Cross-Site Request Forgery is a web security vulnerability that allows an attacker to induce users to perform actions that they do not intend to perform. An attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated. A site is making requests to your site pretending to be another user.

Communication Protocols

  • TCP is a stream-based connection-oriented protocol. TCP provides reliable delivery at a cost of connection setup and retransmission.

  • UDP is a message based and connectionless, UDP starts faster but doesn’t have guaranteed delivery.

Databases and ACID properties

  • Relational databases are fully ACID and require a schema while MongoDB was built as a document based database, with basic atomicity (document level) and no schema. Redis built a fanstatic high performance cache by sacrificing durability by default.

I/O operations

  • Operations that communicate with stuff from the outside of your application like HTTP requests, disk reads, and writes or operations on the database.

Blocking I/O

  • When a client makes a request to connect with the server, the thread that handles that connection is blocked until there is some data to read, or the data is fully written. Until the relevant operation is complete that thread can do nothing else but wait. To fulfill concurrent requests with this approach we need to have multiple threads. This blocking I/O approach is not ideal if you have to cater to a large number of clients

Non-blocking I/O

  • Use a single thread to handle multiple concurrent connections. Instead of writing data onto output streams and reading data from input streams, we read and write data from “buffers”(temporary storage place).
  • “Readiness Selection” which basically means “the ability to choose a socket that will not block when data is read or written”

Async function

  • Can contain an await expression that pauses the execution of the async function and waits for the passed Promise's resolution, and then resumes the async function's execution and returns the resolved value. Remember, the await keyword is only valid inside async functions.” Async functions return a promise. This promise state can be either resolved or rejected. 3. Await suspends the called function execution until the promise returns a result for that execution.
async function demonstration(){
result = await nonExistingApi() //function blocked until resolved         
result2 = await nonExistingApi2() //function blocked until resolved
}

Callback vs promise

A callback function is passed as an argument to another function whereas Promise is something that is achieved or completed in the future

Promise

  • Promises are used to handle asynchronous operations in JavaScript. It is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason.

Scope

Scope essentially means where these variables are available for use.

Hoisting

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.

Var, Let, Const

  • var declarations are globally scoped(outside a function) or function/locally scoped. Var can be redefined and updated within it's scope. e.g var greeter;
  • let is block scoped, a block is a chunk of code bounded by {}. A block lives in curly braces. Anything within curly braces is a block. Let can be updated but can't be redefined within it's scope. e.g. let greeter=1;
  • var is initialized as undefined, the let keyword is not initialized. So if you try to use a let variable before declaration, you'll get a Reference Error.
  • Const variables maintain constant values are block scoped and cannot be updated or re-declared. They must be initialized at the time of declaration. const greeter=1;
  • Const object cannot be updated, the properties of this objects can be updated.
 const greeting = {
        message: "say Hi",
        times: 4
    }

  greeting.message = "say Hello instead";  

Map vs foreach

  • map() method is used to transform the elements of an array, whereas the forEach() method is used to loop through the elements of an array.

Polyfill

  • A piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it.

useRef

  • The Hook allows you to persist values between renders. It can be used to store a mutable value that does not cause a re-render when updated.

APIARCHITECTURE TYPES

REST representational State Transfer

  • Follows six REST architectural constraints
  • 6 architectural constraints which make any web service – a truly RESTful API.
  1. Uniform interface
  2. Client–server
  3. Stateless
  4. Cacheable
  5. Layered system
  6. Code on demand (optional)
  • Can use JSON, XML, HTML or plain test, Uses Http

GraphQL

  • A query language for APIs. Uses a schema to descibe data. Functions using queries and mutations. Uses a single endpoint to fetch specific data. Used in apps requiring low bandwidth

SOAP Simple Object Access Protocol

  • Strictly defined messaging framework that relies on XML. Protocol independent. Secure and extensible. Used in secure environments.

RPC Remote Procedural Call

  • Action based procedure, great for command based systems. Uses only HTTP GET and POST. Has lightweight payloads that allow for high performance. Used for distributed systems.

Apache Kafka

  • Used for live event streaming. Communicates over TCP protocol. Can publish, store and process data as it occurs. Captures and delivers real time data.

Lifecycle methods

  • Are custom functionalities that get executed during the different phases of a component. There are methods available when the component gets created and inserted into the DOM (mounting), when the component updates, and when the component gets unmounted or removed from the DOM.

Lifecycle Components

  • The three phases are: Mounting, Updating, and Unmounting.

structuredClone()

  • Deep clones javascript objects and dates

Barrel file

  • index.ts file used to group and export all the functions and components of other files that are inside the same folder, so that the functions can be imported through a single reference.

Axios

  • A promise-based HTTP client library that can be used in both Node JS and the browser, so we can configure and make requests to a server and receive easy-to-process responses.

Typescript

  • TypeScript is basically a superset of JavaScript only that is has a type system which makes it stricter . "Because TypeScript is a superset of JavaScript, you could also think of JavaScript as a subset of TypeScript. And that means the our entire TypeScript toolchain is perfectly happy to process JavaScript and provide all the services on top of JavaScript,

  • TypeScript is able to identify developmental bugs way before they cause major at runtime.

Static typing

  • When the compiler enforces that values use the same type which means that the data type of a variable has to be the same as the value initially assigned when declaring the same variable in TypeScript

Typescript type vs interface

  • A type cannot be re-opened to add new properties vs an interface which is always extendable.

Enums

  • Enums allow a developer to define a set of named constants. Using enums can make it easier to document intent, or create a set of distinct cases.
  • In a string enum, each member has to be constant-initialized with a string literal, or with another string enum member.
  • Numeric enums can be mixed in computed and constant members. Enums without initializers either need to be first, or have to come after numeric enums initialized with numeric constants or other constant enum members.
enum UserResponse {
  No = 0,
  Yes = 1,
}
 
function respond(recipient: string, message: UserResponse): void {
  // ...
}
 
respond("Princess Caroline", UserResponse.Yes);
enum Direction {
  Up = 1,
  Down,
  Left,
  Right,
}

// Above, we have a numeric enum where Up is initialized with 1. All of the following members are auto-incremented from that point on. In other words, Direction.Up has the value 1, Down has 2, Left has 3, and Right has 4.


enum Direction {
  Up,
  Down,
  Left,
  Right,
}

// Here, Up would have the value 0, Down would have 1, etc. 

IndexedDB

  • A low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high-performance searches of this data.

Celery

  • Celery is a task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well

Multitenancy

  • Multitenancy is a reference to the mode of operation of software where multiple independent instances of one or multiple applications operate in a shared environment. The instances (tenants) are logically isolated, but physically integrated.

Infrastructure Provisioning & Management

Infrastructure Security -

Teleport SSH

HashiCorp Vault

Proper IAM

SSO with Keycloak

Grafana,

Prometheus,

TICK stack,

GCP

Cloud Logging

AWS CloudWatch

Kubernetes (GKE, AWS EKS)

Ansible

Header names

Content-Type(application/json, application/xml, application/x-www-form-urlencoded)

  • Indicates that the request body format.

Accept(application/json, application/json;indent=2, application/xml)

  • Sets output type to JSON.

Airflow

Apache Airflow™ is an open-source platform for developing, scheduling, and monitoring batch-oriented workflows

React Higher Order component

a higher-order component is a function that takes a component and returns a new component.

Closure

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function's scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

function init() {
  var name = "Mozilla"; // name is a local variable created by init
  function displayName() {
    // displayName() is the inner function, that forms the closure
    console.log(name); // use variable declared in the parent function
  }
  displayName();
}
init();

Lexical scoping

  • Describes how a parser resolves variable names when functions are nested. Uses the location where a variable is declared within the source code to determine where that variable is available

Note Space © 2022 — Published with Nextjs

HomeTopicsLinksDefinitionsCommandsSnippetsMy works