Skip to content

Instantly share code, notes, and snippets.

@wiedehopf
wiedehopf / Limit intel turbo boost
Last active November 23, 2024 11:50
N100 PL1 PL2 power limit testing
If the aim is to run some Intel processors as efficient as possible, changing the power limit won't necessarily get it into the efficient frequency for single core loads.
For that it's necessary to set a maximum turbo frequency, this can be done like this:
for freq in /sys/devices/system/cpu/cpufreq/*/scaling_max_freq; do echo 3000000 > $freq; cat $freq; done
The default for N100 is 3.4 GHz which it will only boost to for a single core.
The following testing was done at PL1/PL2 at 15W. (i wouldn't recommend lowering PL1/PL2 below 14 W for efficiency unless you have issues with cooling)
Single core wall power draw for `stress-ng -c 1` stressing a single core:
max_freq pWallSingle geeks geekm geekl
@wiedehopf
wiedehopf / bash_lock.md
Last active June 16, 2024 17:48
bash lock flock

Protecting a bash script against concurrent execution.

This is very simple and easy in bash and probably fine in sh (not tested). The lockfile is never deleted but that is not an issue.

exec 9>>mylockfile

if ! flock --exclusive --nonblock 9; then
 echo "$(date -u +"%FT%T.%3NZ") $$: scriptname will wait for lock"
@wiedehopf
wiedehopf / gist:9fcf92fffd1fb848ef1ea616dc1d1918
Last active October 14, 2023 10:19
wow simming short explanation
https://www.curseforge.com/wow/addons/wowsimsexporter
For search in curseforge app: wowSims Exporter
Ingame type /wse
Export spec / gear
Download sim:
https://github.com/wowsims/wotlk/releases ---> https://github.com/wowsims/wotlk/releases/download/v0.1.41/wowsimwotlk-windows.exe.zip
Extract, copy exe to desktop or wherever you want it.
@wiedehopf
wiedehopf / run-haproxy.sh
Last active September 8, 2022 15:33
haproxy sigterm test
#!/bin/bash
OUTPUT=run-haproxy.log
echo writing log to $OUTPUT
run=0
while sleep 0.00001; do
echo Run $(( ++run )): starting haproxy
echo ---------------------------------------------------
/usr/local/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
@wiedehopf
wiedehopf / sendterm.sh
Last active August 23, 2022 22:34
haproxy SIGTERM test
#!/bin/bash
set -e
function mainpid() {
cat /run/haproxy.pid || true
}
cycles=0
while sleep "0.01"; do
#!/bin/bash
set -e
function mainpid() {
systemctl show --property MainPID haproxy | cut -d= -f2
}
while sleep 0.15; do
OLDPID=$(mainpid)
set cmdheight=2
set number
"set t_Co=256
colorscheme default
set bg=dark
set undofile
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000
import asyncio
import traceback
import time
import zlib
import ujson
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
@wiedehopf
wiedehopf / example.md
Last active June 16, 2024 18:01
Haproxy: Ugly bash script to update ACL entries without reloading haproxy

This would be in the haproxy config:

acl whitelist src -f /etc/haproxy/whitelist.txt

Then you could update the file and then to update haproxy without restarting it using the update-table.sh script:

./update-table.sh whitelist.txt
@wiedehopf
wiedehopf / script.sh
Created January 2, 2021 11:05 — forked from sergeycherepanov/script.sh
shallow update not allowed
Here's what I ended up doing - it worked perfectly. Note that I was moving from my old host (Bitbucket) to my new one (Gitlab). My comments are above the commands:
# First, shallow-clone the old repo to the depth we want to keep
git clone --depth=50 https://[email protected]/....git
# Go into the directory of the clone
cd clonedrepo
# Once in the clone's repo directory, remove the old origin
git remote remove origin