MOVED TO: https://docs.google.com/spreadsheets/d/1pTcBV5lFBdeeBBKr_FhBfL00xHeuDiiTH70_rLK6vx4/edit?usp=sharing
package.json package-lock.json yarn.lock
.env .gitattributes .gitignore .gitmodules
// Note to self: Currently running here: https://dash.cloudflare.com/eb29900091c43bef22edfb71df934698/workers/edit/fanclub | |
/* | |
## Utility Functions | |
*/ | |
const isEmailShaped = email => email && email.length > 5 && email.indexOf('@') > -1 | |
const sendJSON = (data, status = 200) => new Response( | |
typeof data !== 'string' ? JSON.stringify(data) : data, { | |
headers: { 'Content-Type': 'application/json; charset=UTF-8' }, |
package.json package-lock.json yarn.lock
.env .gitattributes .gitignore .gitmodules
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
PARAMS="" | |
DB_HOST="localhost" | |
DB_PORT=27017 | |
DB_DATABASE="local" | |
# DB_COLLECTION="" |
/* | |
The number of stack frames that can | |
(reasonably) be tracked is small (~dozens). | |
When you run code like below, the inner async `writeFile` | |
can 'lose' its prior frame(s) 2 main ways: | |
1. When the outer `forEach` completes (w/ asyncs still running) | |
the stack pops off the completed synchronous frames into | |
the ether. Any later failure may only have a bit of async |
<!-- | |
Semantic Markup === Meaningful code | |
Some semantic markup examples: | |
<nav></nav> | |
<section></section> | |
<main></main> | |
<header></header> |
🎉 All free or open source.
Note: Updated for 2022-24+
#!/bin/bash | |
set -e | |
echo "> CURRENT DNS SERVERS:" | |
networksetup -getdnsservers Wi-Fi | |
networksetup -setdnsservers Wi-Fi \ | |
9.9.9.9 1.1.1.1 8.8.8.8 | |
# Quad 9 Cloudflare Google | |
echo "> DNS SERVERS UPDATED" |
function promiseTimeout(msec) { | |
return (promise) => { | |
let isDone = false | |
promise.then(() => isDone = true) | |
const timeout = new Promise((yea, nah) => setTimeout(() => { | |
if (!isDone) { | |
promise.__timeout = true | |
nah(new Error('Timeout expired')) | |
} | |
}, msec)) |
const isOk = response => response.ok ? response.json() : Promise.reject(new Error('Failed to load data from server')) | |
fetch('https://api.github.com/orgs/nodejs') | |
.then(isOk) // <= Use `isOk` function here | |
.then(data => { | |
console.log(data) // Prints result from `response.json()` | |
}) | |
.catch(error => console.error(error)) |
function promiseTimeout(msec) { | |
return promise => { | |
const timeout = new Promise((yea, nah) => setTimeout(() => nah(new Error('Timeout expired')), msec)) | |
return Promise.race([promise, timeout]) | |
} | |
} | |
promiseTimeout(5000)(fetch('https://api.github.com/orgs/nodejs')) | |
.then(response => response.json()) | |
.then(data => { |