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
/** | |
* environment variables: | |
* WORKING_DIRECTORY - set to absolute path such as /tmp | |
* GIT_REMOTE_{some unique number or key} - set to cloneable HTTPS repo URL such as 'https://github.com/brettinternet/homelab' | |
*/ | |
import { stat } from "node:fs/promises" | |
import { existsSync } from "node:fs" | |
import { dirname, parse as pathParse, join as pathJoin } from "node:path" | |
import { parse as urlParse, fileURLToPath } from "node:url" | |
import { promisify } from "node:util" |
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 createList = (length) => | |
[...new Array(length)].map((_, index) => ({id: (index + 1).toString() })) | |
const length = 10000 | |
const items = createList(length).map(c => ({ ...c, inner: createList(length) })) | |
console.log(items) | |
const lastId = length.toString() | |
const itemId = lastId | |
const innerItemId = lastId |
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 tc = | |
<T extends (...args: Parameters<T>) => ReturnType<T>>( | |
cb: T, | |
condition = true | |
): ((...args: Parameters<T>) => ReturnType<T> | undefined) => | |
(...args: Parameters<T>) => { | |
if (condition) { | |
try { | |
return cb(...args) | |
} catch (error) { |
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 | |
# Work from a terminal you're more comfortable in (and for scrolling) | |
set -xe | |
if passwd -S root | grep -q "NP"; then | |
echo "Set root password:" | |
passwd | |
fi |
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 -e | |
DEPLOYMENTS="$1" | |
NUMBER_OF_REPLICAS="${2:-1}" | |
API_SERVER="https://kubernetes.default.svc" | |
SERVICE_ACCOUNT_FOLDER="/var/run/secrets/kubernetes.io/serviceaccount" | |
NAMESPACE=$(cat ${SERVICE_ACCOUNT_FOLDER}/namespace) |
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 | |
# https://github.com/PrivateBin/PrivateBin | |
if [ ! -f ./conf.ini ]; then | |
curl https://github.com/PrivateBin/PrivateBin/blob/master/cfg/conf.sample.php \ | |
--output ./conf.ini | |
fi | |
mkdir -p tpl |
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 | |
# Source: https://github.com/Morganamilo/paru/issues/707#issuecomment-1116491359 | |
# e.g. paru or yay | |
AUR_HELPER="paru" | |
$AUR_HELPER -Sy | |
g='/Version/{print $3}' |
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
{ | |
"scripts": { | |
"start": "ts-node scripts/start-cra" | |
} | |
} |
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
; Ocassionally moves mouse to a random location | |
; Use Win+z to enable/disable | |
Pause On ; Start paused | |
Loop | |
{ | |
Random, x, -10, 10 | |
Random, y, -10, 10 | |
Random, SleepDelay, 600, 18000 |
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
# Accessing values in maps, keyword lists, and structs | |
# 1. using . they key can’t be missing, works with structs or maps, but not with keyword lists | |
# 2. using […] works on maps and keyword lists, but not structs. Key can be missing and i’ll return nil | |
# 3. Map.get(…) works on maps and structs, but not keyword lists. will return nil if key is missing |