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
// https://brilliant.org/wiki/kaprekars-constant | |
// 4 digits == 6174 | |
// 3 digits (>= 123) == 495 | |
function kaprekar(num) { | |
const sortedSmall = String(num).split('').sort() | |
const sortedBig = sorted.slice().reverse() | |
const a = Number(sortedBig.join('')) | |
const b = Number(sortedSmall.join('')) |
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
my_subdomain.localhost { | |
reverse_proxy localhost:3000 | |
} |
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
if (typeof speechSynthesis === 'undefined') { | |
return; | |
} | |
const name = 'Steven Olsen' | |
console.log(speechSynthesis.getVoices().length, "voices") | |
speechSynthesis.getVoices().forEach((voice, i) => { | |
const utt = new SpeechSynthesisUtterance(`${name} number ${i}`) | |
utt.voice = voice |
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
/* Note: some URLs and logic below may need tweaking!! */ | |
const domain = Deno.env.WEBSITE_DOMAIN; // <<<<<<<<<<<<<<<<<<<<<<<< | |
async function findMaxPageCount() { | |
const r = await fetch(`${domain}/news/`) | |
.then((r) => r.text()) | |
.then((r) => r.replace(/\r?\n/g, "")); | |
// eg. <div class="pagination"><p class="counter pull-right"> Page 1 of 72 </p> | |
return Number(r.match(/class="pagination".*?Page 1 of (\d+)/)?.pop()); |
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-US"> | |
<meta charset="utf-8"> | |
<title>Redirecting…</title> | |
<link rel="canonical" href="/event.ics"> | |
<script>location="/event.ics"</script> | |
<meta http-equiv="refresh" content="0; url=/event.ics"> | |
<meta name="robots" content="noindex"> | |
<h1>Redirecting…</h1> |
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
... | |
"scripts": { | |
"arch": "depcruise --include-only \"^src\" --output-type dot src | dot -T svg > dependencygraph.svg", | |
... | |
"dependencies": { | |
"dependency-cruiser": "^11.16.0", | |
... |
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
import { UserProvider } from "./context" | |
import { Component } from "./component" | |
export default function App() { | |
return ( | |
<UserProvider> | |
<h1>Context App</h1> | |
<Component /> | |
<br /> | |
<Component /> |
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
# https://docs.brev.dev/howto/automatically-set-up/ | |
##### Homebrew ##### | |
(echo ""; echo "##### Homebrew #####"; echo "";) | |
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash - | |
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/brev/.bash_profile | |
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/brev/.zshrc | |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | |
brew install fnm |
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
type AnyFunction = (...args: any[]) => any | |
function useEvent<T extends AnyFunction>(callback?: T) { | |
const ref = useRef<AnyFunction | undefined>(() => { | |
throw new Error("Cannot call an event handler while rendering.") | |
}) | |
useLayoutEffect(() => { | |
ref.current = callback | |
}) | |
return useCallback<AnyFunction>( |
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
// credit: https://www.30secondsofcode.org/articles/s/javascript-object-array-proxy | |
const toKeyedArray = obj => { | |
const methods = { | |
map(target) { | |
return (callback) => | |
Object.keys(target).map(key => callback(target[key], key, target)); | |
}, | |
reduce(target) { | |
return (callback, accumulator) => |