Skip to content

Instantly share code, notes, and snippets.

@enajenkins
enajenkins / building-forex-bot-week1.md
Last active February 4, 2021 08:08
Forex Trading and Bot Algorithms Week 1:

Homework Part 1:

Algorithm - An algorithm is basically a set of rules or instructions that define a logical sequence of operations. In mathematics and computer science, those set of instructions perform a computation that takes an input and provides an output. Any algorithm can be written in any programming language. Algorithms can also be expressed in abstract form using no code at all since, conceptually, it's just a series of logical steps meant to solve a problem. This is usually done to teach algorithmic patterns/concepts or write psuedocode in order to work through an algorithmic solution to your problem before you start to code.

Foreign Exchange - International currency conversion, trading, investing, and price setting that takes place in a distributed/decentralized 24h, M-F global marketplace called the Foreign Exchange Market. The forex market is not a physical exchange like NYSE, but rather a worldwide group of market participants and market makers. The top level of access to

@enajenkins
enajenkins / notes-functions-callbacks-higherorder-firstclass.md
Created January 22, 2021 05:40
Notes: Functions - Callback Functions, Higher Order Functions, and First-Class Functions

Callback Functions, Higher Order Functions, and First-Class Fuctions

  • First-Class Fuctions - functions tha are treated like any other variable. They can be assigned to variables, passed as arguments, and used as the return value of another function.

  • Higher Order Functions - a function that passes in another function as an argument or returns another function as it's return value

  • Callback Functions - a function that's passed to another function as an argument. A common example is asynchronous code. A callback is passed into the function and waits to execute until an async operation like a setTimeout or data fetching is complete. We need callbacks because javascript is an event driven language so rather than waiting for a response before moving on - it continues to execute while listening for other events. Callbacks are a way to make sure certain code doesn’t execute until other code has already finished execution.

Simply put: A callback is a function that is to be executed after another function h

@enajenkins
enajenkins / notes-authentication-https.md
Last active January 23, 2021 10:29
Notes: Authentication and HTTPS

Authentication and HTTPS

Authentication

Basic Authentication Scheme - buitl itnto HTTP and allows the server to protect resources by using HTTP headers to challenge clients for credentials/submit credentials

The server challenge and the client credentials will both be sent by uing HTTP headers.

Cookies - generated by the server to authenticated clients so the cookie can be used for continued verification.

@enajenkins
enajenkins / notes-mongo-and-mongoose.md
Last active January 23, 2021 06:37
Notes: MongoDB and Mongoose ODM

Node, MongoDB, and Mongoose ODM

  • MongoDB is a database technology that uses JSON-like documents instead of Structured Query Language (SQL). It is newer and works well with NodeJS.

  • Mongoose ODM (Object Data Modeling) library makes working together with Node and MongoDB easier.

  • Node was created by Ryan Dahl in 2009. It took the Chrome V8 Javascript Engine and uses it to create a runtime environment for JS outside of the browser so it can be used for server-side applications. Before this, developers had to use a backend language on the server-side.

  • Node uses callbacks and an event loop for a 'non-blocking, asynchronous I/O model'

@enajenkins
enajenkins / notes-node-event-loop.md
Last active January 22, 2021 03:53
Notes: Node Event Loop

Node Event Loop

Six phases of the Node Event Loop

  1. Timer Phase **
  2. Pending Callback Phase
  3. Idle, Prepare Phase
  4. Poll Phase ** where most of the action happens. processes the queue of callbacks and will wait for and process any new request and timers once the queue is empty
  5. Check Phase ** - handles callbacks from setImmediate() timer function when the queue in the poll phase in empty
  6. Close Callbacks Phase - emots the 'close' event if a socket or handle is closed abruptly
@enajenkins
enajenkins / notes-node-modules.md
Last active January 22, 2021 03:55
Notes: Node Modules

Node Modules

  • Javascript was intended for browser scripting and now it's being used for writing full fledged applications

  • JS was not designed with a set of standard libraries that access the underlying hardware and provide a structured way of taking pieces of code from multiple files and combining them together into a single app. Languages like C, C++, Java all have these common libraries.

  • In 2009 CommonJS was created to fill this need. It defined a module format for breaking up a JS app into multiple files or 'modules'. Node and NPM was developed using the CommonJS format for working with modules. The entire Node and NPM ecosystem is built on top of CommonJS

  • Node Modules can be in 3 formats:

  1. External, 3rd-Party: Installed into the node_modules folder using NPM.
@enajenkins
enajenkins / Challenge-Question-Arrays-and-Objects-Question-3.md
Created November 28, 2020 06:32
Challenge Question: Arrays and Objects: Question #3

Let's say you have a MongoDB collection of documents, and you've used a Mongoose/MongoDB Node Driver method such as collection.find() that returns the documents as objects in an array. How would you go about checking to see if a specific object already exists in that array?

@enajenkins
enajenkins / Challenge-Question-Arrays-and-Objects-Question-2.md
Last active November 28, 2020 06:31
Challenge Question: Arrays and Objects: Question #2

Challenge Question: Arrays and Objects:

Question #2:

  1. How can you find the length of an array?
  2. How can you find the number of properties in an object?

Finding the length of an array || arr.length

The .length property returns the number of elements in an array.

let arrayOfAnimals = ["cat", "dog", "rat", "snake"];