This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Callback vs Promise demo | |
* | |
*/ | |
// A callback is nothing more than a parameter. | |
// Instead of accepting a string or object (or int, etc..), we accept | |
// a function instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="root"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const fs = require("fs"); | |
const fspath = require("path"); | |
const url = require("url"); | |
const server = http.createServer(async (request, response) => { | |
const path = url.parse(request.url).pathname; | |
switch (path) { | |
/** | |
* @route '/home' description for route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="root"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function capsFirstLetter(str) { | |
if (typeof str !== "string") { | |
throw new Error("param `str` must be a string!"); | |
} | |
const firstLetterCaps = str[0].toUpperCase(); | |
const restOfString = str.slice(1); | |
return firstLetterCaps + restOfString; | |
} | |
const myStr = "something"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const https = require("https"); | |
const url = require("url"); | |
const server = http.createServer((request, response) => { | |
const path = url.parse(request.url).pathname; | |
switch (path) { | |
/** | |
* This is just documentation comments, doesn't do anything to the code | |
* @route '/' home path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class House { | |
# Lower case bc private | |
hidden [Room[]]$rooms | |
# Constructor (PoSH support overloading, which is huge) | |
House() { | |
$this.rooms = Room[]; | |
} | |
# [Room[]] means our return type is an array of Rooms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class House { | |
constructor() { | |
this.rooms = []; | |
} | |
getRooms() { | |
return this.rooms; | |
} | |
addRoom(name, props) { | |
this.rooms.push({ name, props }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code would live inside the library. | |
*/ | |
class House { | |
// Private | |
#rooms: Array<Room> = []; | |
getRooms(): Array<Room> { | |
return this.#rooms; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const fetch = require("node-fetch"); | |
// Main | |
(async () => { | |
const apiKey = "<your_api_key>"; | |
const symbol = "TSLA"; | |
const from = "2021-06-15"; | |
const to = "2021-06-19"; |