Skip to content

Instantly share code, notes, and snippets.

@kdipaolo
kdipaolo / functional_programming.md
Created January 28, 2019 16:41
functional_programming

first class functions

Functions can be used just like any other value: they can be passed around, assigned to variables, or they can be stored in arrays or objects.


const introduction = () => "Hello! My name is "
const welcome = (name, intro) => intro() + name
welcome("Kurt", introduction()) // Hello! My name is Kurt

Higher order functions

@kdipaolo
kdipaolo / Memoization.rd
Created December 11, 2018 17:53
Memoization
## Test
@kdipaolo
kdipaolo / flexbox.md
Last active December 5, 2018 14:44
Flexbox

Flexbox

  • short for Flexible Box Module
  • Flexbox controls positioning in just one dimension at time (row or column). For two dimension control CSS Grid Layout comes in place

flex-direction

.container {
  flex-direction: row | row-reverse | column | column-reverse;
}
@kdipaolo
kdipaolo / git.md
Last active February 7, 2019 17:53

Remember that the HEAD is Git’s way of referring to the current snapshot

git merge

  • Merging takes the contents of a source branch and integrated them with a target branch. In this process, only the target branch is changed.
  • This will create a "Merge commit" in the feature branch that holds the history of both branches

http://here.streamlinedstudio.com/35d39b314931

git rebase

@kdipaolo
kdipaolo / jwt_auth.md
Created October 30, 2018 12:04
Understanding JSON Web Token Authentication

JWT

Definition

A JSON Web Token (JWT) is a safe, compact, and self-contained way of transmitting information between multiple parties in the form of a JSON object.

Structure

A JSON Web Token consists of three parts that are separated by a “.”. They are: Header, Payload, Signature

Header

The header typically consists of two parts: the token’s type, and the hashing algorithm that is being used.

@kdipaolo
kdipaolo / slice_splice_split.md
Created October 16, 2018 13:40
Slice(), Splice(), Split()

Slice()

array.slice(start, stopAt);

The slice( ) method copies a given part of an array and returns that copied part as a new array. It doesn’t change the original array.

const array = [1,2,3,4,5,6]
const newArray = array.slice(0, 3) // [1, 2, 3]

Execution Contexts

Global Execution Context

The first Execution Context that gets created when the JavaScript engine runs your code is called the “Global Execution Context”.

in the Global Creation phase, the JavaScript engine will:

  1. Create a global object.
  2. Create an object called “this”.
  3. Set up memory space for variables and functions.
  4. Assign variable declarations a default value of “undefined” while placing any function declarations in memory.
@kdipaolo
kdipaolo / graphql-apollo-server-tutorial.md
Last active October 15, 2018 00:35
graphql-apollo-server-tutorial.md

#GraphQL

Apollo Server

can be used with several popular libraries for Node.js: Express, Koa, Hapi. Apollo itself is kept library agnostic, so it is possible to connect it with a lot of third-party libraries in client but also server applications.

GraphQL Yoga (Made by Prisma)

An abstraction around apollo, graphql, express to give you everything you need to create a graphql server

JavaScript: The New Hard Parts (Will Sentance)

JS Code Execution:

What happen when JS executes my code?

2 Parts:

  1. The thread of execution: Walking through the code
  2. A place to store the bits of data (variiable storage)

After a function is done running, its memory gets garbage collected (except for closures)

// In a production application make sure collections are indexed for performance reasons
// Anything you are finding (.find()) on in mongo make sure it is an index