├── javascript ├── index.md ├── mindmap.md ├── src │ └── js_in_one_pic.png ├── date.md ├── js-objects.md ├── javascript-keywords.md ├── prototypal-inheritance-model.md ├── objects.md ├── variables.md ├── data-types.md ├── basic-programming-terms.md ├── document-object-model.md ├── error-handling.md ├── es6-plus-features.md ├── operators.md └── arrays.md ├── vs-code ├── index.md └── shortcuts.md ├── linux-fundamentals ├── 20210924_223400.jpg ├── src │ └── bash-shell.jpg ├── index.md └── cheatsheet.md ├── internet-fundamentals ├── src │ ├── resources.png │ ├── http-messages.png │ ├── tcp-connections.png │ ├── web-architecture.png │ ├── state-and-security.png │ └── dns-lookup-diagram.webp └── index.md ├── index.md ├── react └── react-router-dom.md ├── README.md ├── backend └── express │ └── index.md ├── npm └── index.md └── git-basics └── index.md /javascript/index.md: -------------------------------------------------------------------------------- 1 | # JavaScript 2 | 3 | -------------------------------------------------------------------------------- /javascript/mindmap.md: -------------------------------------------------------------------------------- 1 | # Mind map 2 | 3 | [map link](./src/js_in_one_pic.png) -------------------------------------------------------------------------------- /vs-code/index.md: -------------------------------------------------------------------------------- 1 | # Visual Studio Code 2 | 3 | VS code is an open source editor maintained by Microsoft. 4 | 5 | -------------------------------------------------------------------------------- /javascript/src/js_in_one_pic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/javascript/src/js_in_one_pic.png -------------------------------------------------------------------------------- /linux-fundamentals/20210924_223400.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/linux-fundamentals/20210924_223400.jpg -------------------------------------------------------------------------------- /linux-fundamentals/src/bash-shell.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/linux-fundamentals/src/bash-shell.jpg -------------------------------------------------------------------------------- /internet-fundamentals/src/resources.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/resources.png -------------------------------------------------------------------------------- /javascript/date.md: -------------------------------------------------------------------------------- 1 | # Date Object 2 | 3 | ![date cheat sheet image](https://pbs.twimg.com/media/E3llWveXwAE_5TQ?format=jpg&name=900x900) -------------------------------------------------------------------------------- /internet-fundamentals/src/http-messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/http-messages.png -------------------------------------------------------------------------------- /vs-code/shortcuts.md: -------------------------------------------------------------------------------- 1 | # Shortcuts 2 | 3 | `Ctrl + b` - Toggle Side Bar 4 | 5 | ``Ctrl + ` `` - Toggle Bottom Panel (Terminal, Debug Console) -------------------------------------------------------------------------------- /internet-fundamentals/src/tcp-connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/tcp-connections.png -------------------------------------------------------------------------------- /internet-fundamentals/src/web-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/web-architecture.png -------------------------------------------------------------------------------- /javascript/js-objects.md: -------------------------------------------------------------------------------- 1 | ## Objects 2 | 3 | 4 | ## Objects are compared based on memory location 5 | 6 | 7 | ## Objects are passed by reference -------------------------------------------------------------------------------- /internet-fundamentals/src/state-and-security.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/state-and-security.png -------------------------------------------------------------------------------- /internet-fundamentals/src/dns-lookup-diagram.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codedamn/cheatsheets/HEAD/internet-fundamentals/src/dns-lookup-diagram.webp -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # Cheatsheets 2 | 3 | A simple and elegant way to understand and revise the programming technologies and concepts at one place. 4 | 5 | You can also contribute to the cheatsheets [here](https://github.com/codedamn/cheatsheets) -------------------------------------------------------------------------------- /javascript/javascript-keywords.md: -------------------------------------------------------------------------------- 1 | # JavaScript Keywords 2 | 3 | JavaScript has a total of 63 keywords. 4 | 5 | ## delete 6 | 7 | ## new 8 | 9 | ## let 10 | 11 | ## const 12 | 13 | ## var 14 | 15 | ## for 16 | 17 | ## -------------------------------------------------------------------------------- /react/react-router-dom.md: -------------------------------------------------------------------------------- 1 | # React Router 2 | 3 | ### installation 4 | 5 | `npm install react-router-dom` 6 | 7 | 8 | ### simple example 9 | 10 | ```JSX 11 | import React from 'react'; 12 | import {BrowserRouter, Route, Link, Switch} from 'react-router-dom'; 13 | ``` -------------------------------------------------------------------------------- /javascript/prototypal-inheritance-model.md: -------------------------------------------------------------------------------- 1 | # Prototypal Inheritance Model 2 | 3 | 4 | ## What is \_\_proto\_\_ 5 | 6 | ## Prototypal Chain 7 | 8 | ## getPrototypeOf 9 | 10 | ## Creating an object without the \_\_proto\_\_ 11 | 12 | ## setPrototypeOf 13 | 14 | ## hasOwnProperty 15 | 16 | ## Constructor 17 | 18 | -------------------------------------------------------------------------------- /linux-fundamentals/index.md: -------------------------------------------------------------------------------- 1 | # Linux Fundamentals 2 | 3 | ## `clear` 4 | clears out the entire terminal 5 | 6 | ## `echo` 7 | returns the string which has been passed 8 | 9 | ## What is terminal ? 10 | 11 | ## What is shell ? 12 | 13 | ## What is bash ? 14 | ![bash-shell](./src/bash-shell.jpg) 15 | ## What is difference between terminal and shell ? -------------------------------------------------------------------------------- /javascript/objects.md: -------------------------------------------------------------------------------- 1 | # Objects 2 | 3 | 4 | call by reference in objects 5 | 6 | When we pass an object as a parameter to a function the object is not copied to the parameter but is referenced to the parameter. 7 | So if we try to change the values of properties using the argument we also change the value of the property in the object itself. 8 | 9 | This happens because the object memory location is being referenced in the parameter not the object. as both the top-level and block-level variables access the object using the same memory location the objects value get changed even inside the block level scope. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codedamn Cheatsheets 2 | 3 | This repository hosts the English content of the Codedamn Cheatsheets 4 | 5 | ## Contributions 6 | We are open to contributions and PR's from every Dev around the world. 7 | 8 | You can edit the text in any editor. Cheatsheets uses enhanced "markdown" format, it's easy to grasp and write. 9 | 10 | ## Structure 11 | Every main large topic / a technology has a folder for itself. 12 | Each folder has an `/src` folder which contains all the resources like images. 13 | 14 | index.md stands is the default page for the following folder you are in. 15 | A folder can have multiple .md files, based on the different subsections possible. 16 | 17 | Join our [Discord Server](https://discord.com/invite/brtAY92J2r) for futher doubts and interacting with us. 18 | 19 | It's very easy to add something new. 20 | -------------------------------------------------------------------------------- /javascript/variables.md: -------------------------------------------------------------------------------- 1 | # Variables 2 | 3 | Variable is a a data item / placeholder for a certain data type that may take on more than one value during the runtime of a program. 4 | 5 | There are three keywords for declaring variables in JS. 6 | 7 | 1. `var` (Deprecated) : Declares the variable in global space 8 | 2. `let` : declare the variable. 9 | 10 | If a variable is declared in a block that variable is not accessible in global space 11 | 12 | ```jsx 13 | let myvar = 34; 14 | ``` 15 | 16 | 3. `const` : declare a variable but once declared can not be changed 17 | 18 | 19 | 20 | ## Variable Shadowing 21 | blocking the access to the top level scope variable by defining a variable in the local scope 22 | 23 | ```jsx 24 | const myAge = 17; 25 | function (checkAge) { 26 | let checkAge = 25; 27 | return checkAge > 18 ? true : false; // this is always return true because the function already has a checkAge variable so this function can never access the varaible in the Top Level 28 | ``` -------------------------------------------------------------------------------- /javascript/data-types.md: -------------------------------------------------------------------------------- 1 | # Data Types 2 | 3 | ## Primitive Data types 4 | 5 | ### String 6 | ``` 7 | const name = 'Manoj'; 8 | const name1 = "Harris"; 9 | const result = `The names are ${name} and ${name1}`; 10 | ``` 11 | ### Number 12 | ``` 13 | const number1 = 5; 14 | const number2 = 6.234; 15 | ``` 16 | ### Booleans 17 | ``` 18 | const isTrue = true; 19 | const userFollowed = false; 20 | ``` 21 | ### null 22 | ``` 23 | const name = null; 24 | ``` 25 | ### undefined 26 | ``` 27 | let name1; //undefined 28 | let name2 = undefined; //undefined 29 | ``` 30 | ### symbol 31 | ``` 32 | const value = Symbol('hello'); 33 | ``` 34 | 35 | ## Objects 36 | ``` 37 | const student = { 38 | firstName: 'sampleName', 39 | lastName: null, 40 | class: 12 41 | }; 42 | ``` 43 | 44 | ### Arrays 45 | ``` 46 | // empty array 47 | const myList = [ ]; 48 | 49 | // array of numbers 50 | const numberArray = [ 2, 4, 6, 8]; 51 | 52 | // array of strings 53 | const stringArray = [ 'eat', 'work', 'sleep']; 54 | 55 | // array with mixed data types 56 | const newData = ['work', 'exercise', 1, true]; 57 | ``` 58 | -------------------------------------------------------------------------------- /javascript/basic-programming-terms.md: -------------------------------------------------------------------------------- 1 | ## variable 2 | ## lexical unit 3 | 4 | ## loop 5 | 6 | 7 | ## Data type 8 | 9 | ## Declaration 10 | 11 | ## Expression 12 | 13 | ## Statement 14 | 15 | ## Boilerplate 16 | 17 | ## Difference between Expression and Statement 18 | - **Expressions** always returns a value 19 | Functions are also expressions. Even a non returning function will still return 20 | Functions are also expressions. Even a non returning function will still return value, so it is an expression. 21 | Can print the result value 22 | Examples Of Python Expressions: “Hello” + “World”, 4 + 5 etc. 23 | 24 | - **A statement** never returns a value 25 | Cannot print any result 26 | Examples Of Python Statements: Assignment statements, conditional branching, loops, classes, import, def, try, except, pass, del etc 27 | 28 | ## Assignment 29 | 30 | ## keyword 31 | 32 | ## operator 33 | 34 | ## operand 35 | 36 | ## runtime 37 | 38 | 39 | ## token 40 | 41 | ## syntax 42 | 43 | 44 | ## traverse 45 | 46 | ## iterate / iteration 47 | [more to refer and write from](https://hackr.io/blog/programming-terms-definitions-for-beginners) -------------------------------------------------------------------------------- /javascript/document-object-model.md: -------------------------------------------------------------------------------- 1 | # Document Object Model 2 | 3 | ## Browser Object 4 | ## Document Object 5 | ## .getElementById() 6 | ## .getElementsByClassName() 7 | ## .getElementsByTagName() 8 | ## document.head 9 | ## document.body 10 | ## parentNode, childNode 11 | ## document.getElementById 12 | 13 | ### document.getElementById() v/s document.querySelector() 14 | document.getElementById() is faster compared to querySelector when compared in performance because getElementById uses hashmaps & indexes 15 | 16 | But querySelector can traverse on any other NodeLinks because they are also part of the DOM Tree. 17 | 18 | ```jsx 19 | const ul = document.querySelector('ul'); 20 | const li = ul.querySelector('li'); 21 | 22 | const li = ul.getElementById('#list-item') // this won't work because getElementById can't traverse the NodeList 23 | ``` 24 | 25 | ### ElementNode.innerHTML v/s ElementNode.appendChild 26 | innerHTML resets some properties and can refresh the DOM while appendChild does not disturb other parts of the DOM 27 | ## document.createElement('li') 28 | ## document.appendChild() 29 | ## document.removeChild() 30 | ## setAttribute() 31 | ## removeAttribute() -------------------------------------------------------------------------------- /javascript/error-handling.md: -------------------------------------------------------------------------------- 1 | # Error Handling 2 | 3 | ## try 4 | ``` 5 | try { 6 | // body of try 7 | } 8 | catch(error) { 9 | // body of catch 10 | } 11 | ``` 12 | The main code is inside the `try` block. While executing the `try` block, if any error occurs, it goes to the `catch` block.
13 | If no error occurs, the code inside the `try` block is executed and the `catch` block is skipped. 14 | ## catch 15 | ``` 16 | try { 17 | // body of try 18 | } 19 | catch(error) { 20 | // body of catch 21 | } 22 | ``` 23 | The `catch` block handles the errors as per the catch statements. There can be multiple `catch` followed by a `try` block.
24 | If error occurs, the code inside the `try` block is skipped and the `catch` block is executed. 25 | ## finally 26 | ``` 27 | try { 28 | // try_statements 29 | } 30 | catch(error) { 31 | // catch_statements 32 | } 33 | finally() { 34 | // codes that gets executed anyway 35 | } 36 | ``` 37 | The `finally` block executes both when the code runs **successfully** or if an **error** occurs. 38 | ## throw 39 | You can also use the `throw` statement with the `try...catch` statement to use **user-defined exceptions**. 40 | -------------------------------------------------------------------------------- /backend/express/index.md: -------------------------------------------------------------------------------- 1 | # Express JS 2 | 3 | 4 | Express is a Node.Js library that helps us in writing back-end support for your application 5 | 6 | 7 | ## Setting up a basic server with Express 8 | With the three lines of code you can setup a functional server in Node.js. Now you can open your browser and visit `localhost:3000`, then you'll get a text saying that `Cannot GET /`. If you get this message that means you have successfully setup the server. 9 | ```JavaScript 10 | const express = require('express'); 11 | const app = express(); 12 | 13 | app.listen(3000); 14 | ``` 15 | 16 | The reason why we get the message `Cannot GET /` is because we are not returning a file or status at the `/` route, which is the starting route for any server. 17 | 18 | ## Setting up a basic Route - GET request 19 | ```JSX 20 | const express = require('express'); 21 | const app = express(); 22 | 23 | app.get('/', (req, res, next) => { 24 | res.send('Hello Client!'); 25 | } ) 26 | app.listen(3000); 27 | ``` 28 | 29 | `req` and `res` are standard naming conventions for the callback function as they stand for request and response respectively. 30 | 31 | The third parameter `next` is pretty optional and is not used for 99% of the time. 32 | 33 | -------------------------------------------------------------------------------- /npm/index.md: -------------------------------------------------------------------------------- 1 | # NPM 2 | 3 | NPM is a package manager for Node.JS (JavaScript Runtime Environment). npm is written entirely in JavaScript and was developed by Isaac Z. 4 | 5 | ## `npm i ` (or) `npm install ` 6 | 7 | 8 | ## `npm view ` 9 | 10 | ## `npm init` 11 | 12 | ## `npm init -y` 13 | 14 | ## `npm install -g ` (or) `npm install --global ` 15 | 16 | ## `npm remove ` (or) `npm uninstall ` 17 | 18 | ## `npm root -g` 19 | Shows all the global modules installed on your computer 20 | 21 | ## Dev Dependencies `npm install --save-dev` 22 | 23 | ## Peer Dependencies 24 | 25 | ## NODE_ENV 26 | ### Production 27 | 28 | ### dev 29 | 30 | ## Semantic Versioning (MAJOR.MINOR.PATCH) 31 | 32 | 1. MAJOR should be updated when you make incompatible changes. 33 | 2. MINOR should be updated version when you add functionality in a backwards compatible manner. 34 | 3. PATCH should be updated version when you make backwards compatible bug fixes. 35 | 36 | Example : React 16.3.12 37 | 38 | 16 -> Major Version 39 | 3 -> Minor Version 40 | 12 -> Patch Version 41 | 42 | ## Symbols in Semantic Versioning 43 | 44 | ### ^ 45 | If the version is "^4.0.0" 46 | npm tries to update the package to maximum minor and patch versions available x,y i.e. "4.x.y" 47 | 48 | ### ~ 49 | If the version is "~4.0.0" 50 | npm tries to update the package to maximum of its available patch x i.e. "4.0.x" 51 | 52 | ## NPM Scripts 53 | 54 | 55 | ## npm run 56 | 57 | 58 | ## NPX 59 | npm extended 60 | 61 | npx allows you to run local and global binaries 62 | 63 | 64 | ## changing global modules path 65 | Sometimes you might want to change the location of the global node_modules package location because you don't want to give administrative privileges you can always change the path. 66 | 67 | `npm config set prefix ` 68 | 69 | If you don't want to mention npx while execution global script you can add your global node_modules folder to the environment variables 70 | 71 | ## Cleaning npm cache 72 | 73 | `npm cache clean --force` -------------------------------------------------------------------------------- /internet-fundamentals/index.md: -------------------------------------------------------------------------------- 1 | # Internet Fundamentals 2 | 3 | ## What is the Internet ? 4 | The internet is the wider network that allows computer networks around the world run by companies, governments, universities and other organisations to talk to one another 5 | 6 | ## What is DNS 7 | Stands for **Domain Name System**. In layman terms it is the Phone Book of internet. It translates the human readable website name (Domain Name) to machine readable IP (Internet Protocol) Address 8 | 9 | ## DNS Resolver 10 | It is also called a recursive resolver, is a server designed to receive DNS queries from web browsers and other applications. The resolver receives a hostname - for example, [www.example.com](http://www.example.com/) - and is responsible for tracking down the IP address for that hostname. When it receives the IP, the query is resolved. 11 | 12 | ## DNS Lookup 13 | It is the complete process of finding the IP address for the given domain name 14 | 15 | Sequence of cache checks for finding the IP address for the domain name 16 | 1. Browser Cache 17 | 2. Operating System Cache 18 | 3. Router Cache 19 | 4. ISP DNS Cache 20 | 21 | ![src/dns-lookup-diagram.webp](src/dns-lookup-diagram.webp) 22 | 23 | ## HTTP 24 | Stands for Hyper Text Transfer Protocol 25 | 26 | ### HTTP Status Codes (Categorized) 27 | 28 | `100 - 199` Informational responses 29 | 30 | `200 - 299` Successful responses 31 | 32 | `300 - 399` Redirects 33 | 34 | `400 - 499` Client Errors 35 | 36 | `500 -599` Server Errors 37 | 38 | 39 | ### Port Number 40 | 41 | The default port of http is `80` 42 | 43 | The default port of https is `443` 44 | 45 | ### HTTP Request Methods 46 | 47 | 1. GET 48 | 49 | 1. HEAD 50 | 51 | 1. POST 52 | 53 | 1. PUT 54 | 55 | 1. PATCH 56 | 57 | 1. DELETE 58 | 59 | ### HTTP Request Headers 60 | 61 | To be updated 62 | 63 | ## Infographics 64 | 65 | ![src/resources.png](src/resources.png) 66 | 67 | ![src/http-messages.png](src/http-messages.png) 68 | 69 | ![src/tcp-connections.png](src/tcp-connections.png) 70 | 71 | ![src/web-architecture.png](src/web-architecture.png) 72 | 73 | ![src/state-and-security.png](src/state-and-security.png) 74 | 75 | ## References 76 | 77 | [HTTP response status codes | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) 78 | 79 | [A List of all HTTP Status Codes](https://www.notion.so/c63957d70d7242a29b883ff3532fea50) -------------------------------------------------------------------------------- /git-basics/index.md: -------------------------------------------------------------------------------- 1 | # Git Cheat Sheet 2 | Git is a [Distributed Version Control System](https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control#_distributed_version_control_systems) that helps software developers around the world to store their code by creating versions of it and tracking them. Git also helps in collaborating with other developers and maintaining your code and documenting it for further use. You can [Download Git from here](https://git-scm.com/downloads) 3 | 4 | ## Configuring Credentials 5 | 6 | `git config --global user.name ` 7 | Configuring your name for all the repositories on the local computer 8 | 9 | `git config --global user.email ` 10 | Configuring your email for all the repositories of the local computer 11 | 12 | `git config user.name` 13 | Displays the current name set for the local computer 14 | 15 | `git config user.email` 16 | Display the current email set for the local computer 17 | 18 | ## Basic Commands 19 | 20 | `git init` 21 | Initialize a git repository in the current folder 22 | 23 | `git init ` 24 | Create an empty folder and initialize a git repository 25 | 26 | `git add ` 27 | Adds the following file to the staging area 28 | 29 | `git add .` 30 | Adds all the files to the staging area 31 | 32 | `git commit -m "` 36 | Linking your Local repo to the remote repo 37 | 38 | `git push --set-upstream ` 39 | Setting the upstream branch to push the code 40 | 41 | `git push` 42 | Sending the code from local repo to remote repo 43 | 44 | `git clone ` 45 | Creating a new folder and copying the code from remote repo 46 | to your local computer 47 | 48 | `git pull` 49 | Getting the new changes from the remote repo and merging 50 | them with your local repo 51 | 52 | `git status` 53 | It shows the list of all files that we have changed or needs to be changed 54 | 55 | `git log` 56 | Gets the history of all commits in reverse chronological order 57 | 58 | ## Branches 59 | 60 | `git branch ` 61 | Creates a new branch with the `` 62 | 63 | `git checkout ` 64 | Moves the head to the `` 65 | 66 | `git checkout -b ` 67 | Creates a new branch (if not exists) and checkouts to the created branch 68 | 69 | 72 | -------------------------------------------------------------------------------- /javascript/es6-plus-features.md: -------------------------------------------------------------------------------- 1 | # ES6+ Features 2 | ES6 stands for ECMA Script Standards 6 / ES6 / ES 2015. The following features were approved by the ECMA International / ECMA technical committee in the year 2015 and is called ES6 because it is the sixth release of features / rules. 3 | 4 | ## Arrow Functions `ES6` 5 | ### Single Line Functions 6 | 7 | 8 | ## Destructuring 9 | #### Destructuring Object - 1 10 | 11 | ```jsx 12 | let myObj = { 13 | name : "John Doe", 14 | dob : " 13012004", 15 | height: 176, 16 | weight : 79, 17 | eyes : "brown"} 18 | 19 | // Destructuring the object 20 | let {name, dob, height, weight, eyes} = myObj; 21 | console.log(name) // John Doe 22 | console.log(eyes) // brown 23 | ``` 24 | 25 | #### Destructuring Object - 2 `Spread syntax (...)` 26 | 27 | ```jsx 28 | let myObj = { 29 | name : "John Doe", 30 | dob : " 13012004", 31 | height: 176, 32 | weight : 79, 33 | eyes **: "brown"} 34 | let {name, dob, ...rest} = myObj; 35 | console.log(name) //John Doe 36 | console.log(rest) /*{height: 176, 37 | weight : 79, 38 | eyes: "brown"} */ 39 | ``` 40 | ### Array Destructuring 41 | ### Object Destructuring 42 | ### What happens to Overlapping keys ? 43 | 44 | ## Exporting 45 | There are basically two export statements 46 | 47 | #### `export` 48 | 49 | ```jsx 50 | // filename : heading.js 51 | export const heading = "This is my heading"; 52 | ``` 53 | 54 | If we export just using the `export` statement then at the time of import the variable name should match and we must keep the variable in `{}` to import it as an object. 55 | 56 | ```jsx 57 | // filename : index.js 58 | import {heading} from './heading'; 59 | ``` 60 | 61 | #### `export default` 62 | 63 | ```jsx 64 | // filename : heading.js 65 | const heading = "This is my heading"; 66 | export default heading; 67 | ``` 68 | 69 | If we use the `default export` statement then at the time of import we can have our own variable i.e. the export variable need not be the same as import variable 70 | 71 | ```jsx 72 | // filename : index.js 73 | import newHeading from './heading'; 74 | ``` 75 | 76 | ## Short Circuit Evaluation 77 | ### `||` 78 | 79 | ```jsx 80 | const firstValue = '' || 'myName'; // myName 81 | ``` 82 | If the first value is `falsy` then the second value is returned. If the first value is `truthy` then the first value is returned 83 | ### `&&` 84 | 85 | ```jsx 86 | const firstName = 'myName' && 'myNickName'; // myNickName 87 | ``` 88 | If the any of the value is `falsy` then nothing will be returned. if both the values are `truthy` then the second value is returned. -------------------------------------------------------------------------------- /javascript/operators.md: -------------------------------------------------------------------------------- 1 | # Operators 2 | 3 | ## **Bitwise Operators** 4 | ### `&` ### AND 5 | ### `|` ### OR 6 | ### `~` ### NOT 7 | ### `^` ### XOR 8 | 9 | ### `,`(Comma) operator 10 | to evaluate multiple expressions in one line 11 | 12 | ```jsx 13 | for (var i = 0,j = 10; i <= 3; i++ , j++ ) { 14 | console.log('Floor no : ' + i + 'Flat no : ' + j 15 | } 16 | ``` 17 | 18 | ### `new` operator 19 | create an instance of a user-defined object type or of one of the build-in object types that has a constructor function 20 | 21 | ```jsx 22 | let currentDate = new Date(); 23 | ``` 24 | 25 | ### `delete` operator 26 | removes a property from an object. If no more reference to the same property are held, it is eventually released automatically 27 | 28 | ```jsx 29 | var admin = { 30 | isCoding : true, 31 | isLearning : false } 32 | console.log(admin.isCoding) // true 33 | delete admin.isCoding 34 | console.log(admin.isCoding) // undefined 35 | ``` 36 | 37 | ### `in` operator 38 | returns true if hte specified property is in the specified object or its prototype chain 39 | 40 | ```jsx 41 | const user = { 42 | name : 'John Doe', 43 | profession : 'web dev', 44 | age : 40, 45 | nationality : 'Indian' 46 | } 47 | console.log("name" in user) // true 48 | console.log("salary" in user) // false 49 | ``` 50 | 51 | ### `instanceof` operator 52 | to check the type of an object at run time. It returns a boolean value that indicates if an object is an instance of a particular class 53 | 54 | ```jsx 55 | var newString = newString('This is a new string') // string object 56 | console.log(newString instanceof String) // true 57 | ``` 58 | 59 | ### `this` 60 | used to refer the current object. In general refers to the calling object in a method 61 | 62 | ```jsx 63 | var person = { 64 | firstName : 'John', 65 | lastName : 'Doe', 66 | fullName : () => this.firstName + ' ' + this.lastName; 67 | }; 68 | ``` 69 | 70 | ### `typeof` 71 | returns the data type of the operand 72 | 73 | ```jsx 74 | let name = 'John Doe' 75 | let myObj = { 76 | desktop : false, 77 | laptop : true} 78 | 79 | console.log(typeof name) // string 80 | console.log(typeof myObj) // object 81 | ``` 82 | 83 | ### `?` Ternary Operator 84 | 85 | ### `??` Nullish coalescing operator 86 | returns its right-hand side operand when its left-hand side operand is `null` or `undefined`, and otherwise returns its left-hand side operand. 87 | 88 | ```jsx 89 | undefined ?? 'something' // something 90 | 0 ?? 'something' //0 91 | ``` 92 | 93 | `??` is almost similar to `||` but `||` returns other value when `false` but `??` returns other value when the first value is `null` or `undefined` -------------------------------------------------------------------------------- /javascript/arrays.md: -------------------------------------------------------------------------------- 1 | # Arrays 2 | 3 | 4 | ## Array Methods 5 | 6 | ### `.push()` 7 | 8 | ```jsx 9 | let fruits = ['Apple','Banana']; 10 | let newLength = fruits.push('Orange'); 11 | console.log(fruits) // ['Apple','Banana'] 12 | console.log(newLength) // ['Apple','Banana','Orange'] 13 | 14 | ``` 15 | 16 | ### `.shift()` 17 | ### `.unshift()` 18 | ### `.pop()` 19 | ### `.findLast()` 20 | ### `.findLastIndex()` 21 | ### `.splice()` 22 | 23 | splice has 2 mandatory arguments [index, no of elements to be removed] 24 | 25 | splice also returns the list of the removed elements 26 | 27 | splice can have n number of arguments after the first two mandatory arguments. all the n number of arguments are added to the array from the index as mentioned in the first argument 28 | 29 | ### `.slice()` 30 | 31 | takes two arguments [start index, stop index] 32 | 33 | slice leaves the passed array untouched and returns the elements as mentioned in the argument 34 | 35 | ### `.map()` 36 | 37 | map calls a provided callbackFn function once for each element in an array, in order, and constructs a new array from the results. callbackFn is invoked only for indexes of the array which have assigned values (including undefined). 38 | 39 | ```jsx 40 | let numbers = [1, 4, 9] 41 | let roots = numbers.map(function(num) { 42 | return Math.sqrt(num) 43 | }) 44 | // roots is now [1, 2, 3] 45 | // numbers is still [1, 4, 9] 46 | ``` 47 | 48 | ### `.filter()` 49 | 50 | .filter() method creates a new element in the new array if the return statement of the element in the callback function is true 51 | 52 | ```jsx 53 | const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; 54 | 55 | const result = words.filter(word => word.length > 6); 56 | 57 | console.log(result); 58 | // expected output: Array ["exuberant", "destruction", "present"] 59 | ``` 60 | 61 | ### `.reduce()` 62 | 63 | [Learn JavaScript Array Reduce In 10 Minutes](https://www.youtube.com/watch?v=s1XVfm5mIuU) 64 | 65 | ### `.forEach()` 66 | 67 | takes a callback and traverses to the entire array. 68 | 69 | ```jsx 70 | const array1 = ['a', 'b', 'c']; 71 | 72 | array1.forEach(element => console.log(element)); 73 | 74 | // expected output: "a" 75 | // expected output: "b" 76 | // expected output: "c" 77 | ``` 78 | 79 | ### `.indexOf()` 80 | 81 | argument : value 82 | 83 | if the argument exists in the given list the `index` of the element which matches with the argument is returned else `-1` is returned 84 | 85 | ### `.includes()` `**ES 6**` 86 | 87 | .includes simply returns boolean. Returns true if the argument passed exists in the array or return false if not found in the array 88 | 89 | ### `.find()` 90 | 91 | takes a callback function and -------------------------------------------------------------------------------- /linux-fundamentals/cheatsheet.md: -------------------------------------------------------------------------------- 1 | # Linux Commands Cheat sheet 2 | 3 | ## `cd` 4 | This is a command to set the current working directory. 5 | ### Eg: `cd Downloads` 6 |
7 | 8 | ## `ls` 9 | This is a command to list the contents of the current directory. 10 | ### Eg: `ls Downloads` 11 |
12 | 13 | ## `cat` 14 | This is a command which reads a specified file and sequentially and writes the contents to standard output. 15 | ### Eg: `cat index.js` 16 |
17 | 18 | ## `mkdir` 19 | This is a command to create a directory. 20 | ### Eg: `mkdir Images` 21 |
22 | 23 | ## `touch` 24 | This command is used to create a file without any content. The file created using touch command is empty.. 25 | ### Eg: `touch index.js` 26 |
27 | 28 | ## `less` 29 | This command displays the contents of a file or a command output, one page at a time 30 | ### Eg: `less ` 31 |
32 | 33 | ## `clear` 34 | Clears the contents of the terminal screen 35 |
36 | 37 | ## `pwd` 38 | This is a commands prints the full path name of the current working directory. 39 | ### Eg: `pwd` 40 | ### Output: `/home/myProject` 41 |
42 | 43 | ## `mv` 44 | This command is used to rename and moves one or more files or directory from one location to another. 45 | ### Eg: `mv SOURCE DESTINATION` 46 |
47 | 48 | ## `cp` 49 | This command used for copying files and directories. 50 | ### Eg: `cp SOURCE DESTINATION` 51 |
52 | 53 | ## `rm` 54 | This command used to remove a file. 55 | ### Eg: `rm
` 56 |
57 | 58 | ## `nano` 59 | This is an easy to use text editor that runs in the terminal. 60 | ### Eg: `nano
` 61 |
62 | 63 | ## `chmod` 64 | This command is used to change the access permissions of file system objects. 65 | ### Eg: `chmod 400 test.pem` 66 | To learn more about the numerical permissions visit
here 67 |
68 | 69 | ## `ssh` 70 | This command provides a secure encrypted connection between two hosts over an insecure network. 71 | ### Eg: `ssh HOSTNAME COMMAND` 72 |
73 | 74 | ## `ping` 75 | This command checks if the specified host is reachable. 76 | ### Eg: `ping google.com` 77 |
78 | 79 | ## `df` 80 | This command shows the amount of disk space used and available on Linux file systems. 81 | ### Eg: `df` 82 |
83 | 84 | ## `du` 85 | This command shows the amount of disk space used by the specified files and for each subdirectorys. 86 | ### Eg: `du` 87 |
88 | 89 | ## `grep` 90 | This command used for searching plain-text data sets for lines that match a regular expression. 91 | ### Eg: `grep [options] pattern [files]` 92 |
93 | 94 | ## `tar` 95 | This command used for archiving and extract the archive files. 96 | ### Eg: `tar [options] [archive-files]` 97 |
98 | 99 | ## `kill` 100 | This command is used to terminate a running process in the system. 101 | ### Eg: `kill [options] [pid]` 102 | pid stands for process id 103 |
104 | 105 | ## `ps` 106 | This command outputs the currently running processes in the system with it's `pid`. 107 | ### Eg: `ps [options]` 108 |
109 | 110 | ## `echo` 111 | This command is used to move some data into a file. 112 | ### Eg: `echo console.log('Hello, World!); >> index.js` 113 | 114 | The above example shows that the line `console.log('Hello, World!);` is beign written into the `index.js` file. 115 |
116 | 117 | 118 | ## `man` 119 | This command is used to display the user manual of any command that we can run on the terminal 120 | ### Eg: `man cd` 121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | --------------------------------------------------------------------------------