Skip to content

Instantly share code, notes, and snippets.

View oze4's full-sized avatar
♠️
👋

Matt Oestreich oze4

♠️
👋
View GitHub Profile
@oze4
oze4 / callbackVsPromise.js
Last active December 6, 2021 19:55
callback h311
/**
*
* 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.
@oze4
oze4 / react.babel.html
Created November 15, 2021 07:19
React/Babel
<!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>
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
@oze4
oze4 / babel.ts.html
Created August 29, 2021 17:19
Babel+TS in browser
<!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>
@oze4
oze4 / capsFirstLetter.js
Created August 21, 2021 16:12
caps first letter in str
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";
@oze4
oze4 / index.js
Created August 11, 2021 19:41
ssrPocNodeJS.js
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
@oze4
oze4 / House.ps1
Created July 30, 2021 18:46
House
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
class House {
constructor() {
this.rooms = [];
}
getRooms() {
return this.rooms;
}
addRoom(name, props) {
this.rooms.push({ name, props });
}
@oze4
oze4 / house.ts
Last active July 30, 2021 00:25
House class with rooms
/**
* This code would live inside the library.
*/
class House {
// Private
#rooms: Array<Room> = [];
getRooms(): Array<Room> {
return this.#rooms;
@oze4
oze4 / findDailyHigh30MinTimeFrame.js
Last active July 4, 2021 05:26
fmpcloud.io locate in which 30 min time frame the high of the day occurred.
#!/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";