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 re | |
import niquests | |
import sys | |
from bs4 import BeautifulSoup | |
def parse_page(soup): | |
drives = soup.find_all(class_="boost-pfs-filter-product-bottom") | |
for drive in drives: |
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
#!/usr/bin/env sh | |
set -e | |
pw=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 20) | |
iterations=100000 | |
eval $(echo -n "$pw" | openssl enc -pbkdf2 -pass pass:/dev/stdin -aes-256-cbc -P -md sha256 -iter $iterations | grep -E '^(salt|key)') | |
pwHash={PBKDF2}${iterations}\$${salt}\$${key} | |
echo "$pwHash" |
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
-- create log table (source side) | |
CREATE TABLE ddl_log ( | |
id integer PRIMARY KEY, | |
object_tag TEXT, | |
ddl_command TEXT, | |
timestamp TIMESTAMP | |
); | |
CREATE SEQUENCE ddl_log_seq; | |
-- create log function (source side) |
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
K8S_VERSION_MINOR=1.29 | |
# Repos for cri-o | |
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key | | |
gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg | |
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/v${K8S_VERSION_MINOR}/deb/ /" | | |
tee /etc/apt/sources.list.d/cri-o.list | |
# Repo for Kubernetes tools/components | |
curl -fsSL https://pkgs.k8s.io/core:/stable:/v${K8S_VERSION_MINOR}/deb/Release.key | |
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
# 1. Find colored lines | |
# 2. Strip out useless lines | |
# 3. Strip empty "colored" lines | |
grep --color=never $'\x1b''\[[0-9;]*' \ | |
| grep -vE 'Terraform has been|Initializing |use this backend unless the backend configuration changes|commands will detect it and remind you to do so if necessary|Refreshing state...|Read complete after |Reading...| copy_backend_before_init |Terraform has compared your real infrastructure|No changes.' \ | |
| sed -E '/^'$'\x1b''\[0m'$'\x1b''\[32m/d' |
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
sudo dnf install -y VirtualBox-server | |
# Make a vhd | |
qemu-img create -f vpc test.vhd 8G | |
virt-format -a test.vhd --partition=gpt --filesystem=ntfs | |
echo 'write /readme.txt "readme"' | guestfish -a test.vhd -m /dev/sda1 | |
mkdir test | |
vboximg-mount --image $(pwd)/test.vhd --rw --root test | |
mkdir testfs |
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
docker run --rm --privileged --pid=host ubuntu:22.04 \ | |
nsenter -t 1 -m -u -n -i \ | |
sh -c "sed -i '/enable-admission-plugins/{/NamespaceAutoProvision/b; s/$/,NamespaceAutoProvision/}' /etc/kubernetes/manifests/kube-apiserver.yaml" |
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
python3 -c ' | |
import json | |
import sys | |
from urllib.parse import urlparse, parse_qs | |
print(json.dumps(parse_qs(urlparse(sys.argv[1]).query))) | |
' |
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
""" | |
See section about "Reading and writing cache files" for how this works | |
with QDirStat https://github.com/shundhammer/qdirstat/blob/master/README.md?plain=1#L848 | |
`borg list` should run without prompting for credentials. See borg docs for configuring | |
environment variables https://borgbackup.readthedocs.io/en/stable/quickstart.html#automating-backups | |
""" | |
import dataclasses | |
import datetime | |
import gzip |
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
def fix_truncated_json(err_json: str) -> str: | |
"""closes open delimiters so json is parseable""" | |
stack = [] | |
expect_literal = False | |
last_literal = [] | |
for i, c in enumerate(err_json): | |
if c == '"': | |
if i > 0 and err_json[i-1] == '\\': | |
continue | |
if stack[-1] == '"': |
NewerOlder