Skip to content

Instantly share code, notes, and snippets.

View D4R4's full-sized avatar

Dara Ardalan D4R4

  • SCALINX
  • Paris, France
View GitHub Profile
@D4R4
D4R4 / Immortal_Windows.ps1
Created July 6, 2026 00:55
Immortal Windows - disable and stop update/sleep/crashers as much as possible
$auPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
New-Item -Path $auPath -Force | Out-Null
Set-ItemProperty -Path $auPath -Name "NoAutoUpdate" -Value 1 -Type DWord
Set-ItemProperty -Path $auPath -Name "AUOptions" -Value 2 -Type DWord
Set-ItemProperty -Path $auPath -Name "NoAutoRebootWithLoggedOnUsers" -Value 1 -Type DWord
$wuPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
New-Item -Path $wuPath -Force | Out-Null
Set-ItemProperty -Path $wuPath -Name "DeferFeatureUpdatesPeriodInDays" -Value 365 -Type DWord
Set-ItemProperty -Path $wuPath -Name "DeferQualityUpdatesPeriodInDays" -Value 30 -Type DWord
@D4R4
D4R4 / rsync.sh
Created June 30, 2026 16:32
Rsync with proper switches
rsync -ax --delete --numeric-ids --info=progress2 <SRC> <DST>
@D4R4
D4R4 / fio_jobs.sh
Created June 26, 2026 09:46
Useful FIO examples
# mix
fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=fiotest --filename=testfio --bs=4k --iodepth=64 --size=8G --readwrite=randrw --rwmixread=75
# write
fio --name=randwrite --ioengine=libaio --iodepth=1 --rw=randwrite --bs=4k --direct=1 --size=1G --numjobs=1 --runtime=60 --time_based --group_reporting
# read
fio --name=test --ioengine=sync --iodepth=1 --rw=randread --bs=4k --numjobs=1 --size=1G --runtime=30s --time_based
@D4R4
D4R4 / nfs_socker_flush.sh
Created June 26, 2026 09:27
Flush stuck NFS socket at network layer
# On client
ss -K dst <SERVER_IP> dport = 2049
# On server
iptables -I INPUT -s <CLIENT_IP> -p tcp -m tcp --sport 828 --dport 2049 -j REJECT --reject-with tcp-reset; sleep 60; iptables -D INPUT -s <CLIENT_IP> -p tcp -m tcp --sport 828 --dport 2049 -j REJECT --reject-with tcp-reset
@D4R4
D4R4 / stuck_io_procs.sh
Created June 26, 2026 09:26
Show processes with stuck IO
ps -eo pid,comm,stat,wchan | grep ' D '
@D4R4
D4R4 / NFS_freenodes_report.sh
Created June 26, 2026 09:25
NFS server free node report
while :; do date; sysctl -n vfs.numvnodes kern.maxvnodes vfs.wantfreevnodes; sleep 3; done
@D4R4
D4R4 / flush_nfs_lock.sh
Created June 26, 2026 09:24
Flushing stuck NFS lock
touch /share/test.txt
service rpcbind stop
service nfslock stop
rm -rf /var/lib/nfs/statd/sm/*
rm -rf /var/lib/nfs/statd/sm.bak/*
umount /share -f
service rpcbind stop
service nfslock stop
umount /share -f
lsof | grep /users/
@D4R4
D4R4 / ad_user_pw_check.cmd
Last active June 1, 2026 08:19
Check AD user password
runas /user:DOMAIN\ttest cmd
@D4R4
D4R4 / .htaccess
Created March 10, 2023 11:53
Here's the htaccess code to allow everything in CSP
<ifModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff
Header set X-Frame-Options DENY
Header add Content-Security-Policy "default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' 'unsafe-dynamic'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';"
</ifModule>
@D4R4
D4R4 / cpu.sh
Last active June 26, 2026 09:48
CPU performance metrics and tuning
uname -a
lsb_release -a
lscpu | grep "MHz".
sudo dmidecode -t processor | grep "Speed"
lshw -c cpu | egrep "capacity|size"
sudo lshw -c cpu | egrep "capacity|size"
head /sys/devices/system/cpu/cpu0/cpufreq/scaling_*
yum install -y powertop
powertop