go install -v tailscale.com/cmd/tailscale{,d}@latest
sudo tailscaled install-system-daemon
tailscale up
# login, approve
tailscale status
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 MAX_INFLIGHT = 4; | |
const TOTAL = 100; | |
// the given dummy api supports a maximum of 4 of inflight requests. | |
// the given code is correct, but it is slow because it processes elements serially. | |
// your task is to process 100 elements as fast as possible. | |
// run this code with "node/bun test.js". | |
// it should print "pass". | |
// no external dependencies are allowed. | |
async function run(elements) { | |
// ============ |
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
#!/bin/bash | |
set -euf -o pipefail | |
if [ ! -f code-server ]; then | |
ARCH=$(uname -m) | |
OS="unknown-linux-gnu" | |
echo "downloading code-server ($ARCH-$OS)" | |
URL="https://vscodeserverlauncher.blob.core.windows.net/builds/latestbin/$ARCH-$OS/$ARCH-$OS" | |
curl -L "$URL" >code-server | |
chmod +x code-server |
-
Setup multipass https://multipass.run/
-
Setup XQuartz https://www.xquartz.org/
-
Run ubuntu and connect over ssh
-
Setup mininet http://mininet.org/ with
sudo apt install mininet
-
Open one tab with Wireshark, using
ssh -X ubuntu@<ip> sudo -E wireshark
-
Setup
npx create-vite # vanilla # typescript # enter name cd name/ npm install reveal.js
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
func typeCache[T any](compute func(t reflect.Type) T) func(t reflect.Type) T { | |
cache := map[reflect.Type]T{} | |
return func(t reflect.Type) T { | |
if v, ok := cache[t]; ok { | |
return v | |
} | |
v := compute(t) // but compute cant recurse | |
cache[t] = v | |
return v | |
} |
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
import { useCallback, useEffect, useState } from 'react' | |
// borrowed from https://usehooks.com/useAsync/ | |
export function useAsync<T>(asyncFunction: () => Promise<T>, immediate = true) { | |
const [loading, setLoading] = useState(true) | |
const [value, setValue] = useState<T | null>(null) | |
const [error, setError] = useState<any>(null) | |
// The execute function wraps asyncFunction and | |
// handles setting state for pending, value, and error. | |
// useCallback ensures the below useEffect is not called |
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
#!/bin/bash | |
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename> | |
ID="...." | |
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \ | |
--data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed \ | |
jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL') | |
curl "$URL" -o myfile.ext |
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
//scale returns the number scaled to its corresponding SI suffix. | |
// scale(1234) => "1.2 K" | |
//MIT License, Copyright jpillora © 2019 | |
function scale(n, d) { | |
// set default number | |
if (typeof n !== "number" || isNaN(n)) n = 0; | |
if (n === 0) return "0"; | |
// set default digit count | |
if (typeof d !== "number" || isNaN(d)) d = 1; | |
// find scale index 1000,100000,... becomes 1,2,... |
NewerOlder