Skip to content

Instantly share code, notes, and snippets.

@coleplx
coleplx / oci_ubuntu_to_debian.multiarch.sh
Created June 8, 2024 17:14 — forked from ishad0w/README.md
Debian 12 on Oracle Cloud (Free Tier) - (AMD64/ARM64)
#!/bin/bash
echo -e "\nHost:"
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -p 22 ubuntu@$1 \
'uname -a && arch && uptime && sudo touch /home/ubuntu/.hushlogin /root/.hushlogin'
echo -e "\nAdding temporary SSH-key for Ubuntu root user..."
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -p 22 ubuntu@$1 \
'sudo cat /home/ubuntu/.ssh/authorized_keys | sudo tee /root/.ssh/authorized_keys'
echo -e "\nSystem trimming..."
@coleplx
coleplx / beta_cycling.sh
Last active May 19, 2022 20:15
Beta Cycling script
#!/bin/bash
RUNNING_STAGINGS=$(ls -ld /sys/fs/cgroup/memory/lxc.payload* | rev | cut -d'.' -f1 | rev | grep '\-staging\-')
### LXD API IMPLEMENTATION
get_stderr_code() {
id_container=$1
id_operation=$2
stderr_log=$(curl -s --unix-socket /var/snap/lxd/common/lxd/unix.socket lxd/1.0/instances/${id_container}/logs/exec_${id_operation}.stderr)
}
@coleplx
coleplx / throttle-and-debounce.sh
Created August 2, 2019 18:51 — forked from niieani/throttle-and-debounce.sh
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"