Skip to content

Instantly share code, notes, and snippets.

@zax4r0
Last active July 9, 2025 05:55
Show Gist options
  • Select an option

  • Save zax4r0/ff818396b8fcca92ade4174606608995 to your computer and use it in GitHub Desktop.

Select an option

Save zax4r0/ff818396b8fcca92ade4174606608995 to your computer and use it in GitHub Desktop.
scripts
#!/bin/sh
###############
# Cycle windows
# (C) 2024 zax4r0 <[email protected]>
# GNU General Public License v3.0
###############
timer_file=$(dirname $(realpath "$0"))"/alt_tab_timer.txt"
if [[ $(( $(date +%s%N | cut -b1-13 ) - $(cat "$timer_file") )) -ge 1000 ]]
then
xdotool keydown alt
fi
date +%s%N | cut -b1-13 > "$timer_file"
case "$@" in
shift)
xdotool key Shift+Tab
;;
*)
xdotool key Tab
;;
esac
sleep 1
if [[ $(( $(date +%s%N | cut -b1-13) - $(cat "$timer_file") )) -ge 1000 ]]
then
xdotool keyup alt
fi
#!/bin/bash
# Desired limits
CPUS=4.0
MEMORY=8g
SWAP=8g
for c in $(docker ps -q); do
name=$(docker inspect --format='{{.Name}}' "$c" | sed 's/^\/\(.*\)/\1/')
echo "Updating container: $name ($c)"
# Apply limits
if docker update --cpus="$CPUS" --memory="$MEMORY" --memory-swap="$SWAP" "$c"; then
echo "✅ Successfully updated: $name"
echo "Applied limits:"
docker inspect "$c" | grep -i -E '"NanoCpus"|"Memory"|"MemorySwap"'
else
echo "❌ Failed to update: $name"
fi
echo "-------------------------------"
done

sudo systemctl edit docker

[Service] ExecStart= ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock ExecReload=/bin/kill -s HUP $MAINPID TimeoutStartSec=0 RestartSec=2 Restart=always

Resource limits for Docker daemon

AllowedCPUs=0-11 MemoryMax=12G MemorySwapMax=24G

Recommended Docker systemd settings

LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process OOMScoreAdjust=-500 EOF

sudo systemctl daemon-reexec sudo systemctl daemon-reload sudo systemctl restart docker

systemctl cat docker.service

systemctl status docker systemctl show docker | grep -E 'MemoryMax|CPUQuota|AllowedCPUs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment