This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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"; |
This file contains hidden or 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 | |
/** | |
* Use this function like: | |
* `getRelativeDate("before", 3, new Date("7/2/1992"));` | |
* | |
* @param {String} beforeOrAfter ("after"|"before") | |
* @param {Number} numberOfDays number of days before or after the 'date' param | |
* @param {Date} date the 'RelativeToDate' in 'getDateRelativeToDate' | |
* | |
* @return * If "before" or "after" is not used as the value of the `beforeOrAfter` |
This file contains hidden or 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
func prettyPrint(i interface{}) { | |
prettyJSON, err := json.MarshalIndent(i, "", " ") | |
if err != nil { | |
fmt.Printf("Error : %s \n", err.Error()) | |
} | |
fmt.Printf("%s\n", string(prettyJSON)) | |
} |
This file contains hidden or 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 { log } = console; | |
// This just lets us block the event loop | |
const workFor = 5 // seconds | |
const work = (s = workFor) => new Promise(r => setTimeout(r, s * 1000)); | |
const appPort = 8888 | |
let reqCount = 0 |