Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
AnatomicJC / prevent-desktop-lock.md
Created August 9, 2023 14:07
Prevent desktop lock or screensaver with PowerShell
Add-Type -AssemblyName System.Windows.Forms

$sleep = 240

$i = 0
while ($true) {
  $Pos = [System.Windows.Forms.Cursor]::Position
  if (($i % 2) -eq 0) {
 [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) + 1) , $Pos.Y)
@AnatomicJC
AnatomicJC / protect_data.md
Last active September 1, 2023 19:05
Ansible callback plugin to hide sensitive data such as passwords from screen output

With the below settings, each variable content containing vault, pwd or pass will be obfuscated.

In ansible.cfg:

# Enable plugin
[defaults]
stdout_callback = protect_data

[callback_protect_data]
@AnatomicJC
AnatomicJC / check_cpu_load.md
Last active December 29, 2024 11:26
Check CPU load

Script Bash pour surveiller la charge CPU et redémarrer HAProxy

Voici un script Bash qui vérifie la charge CPU et redémarre le service HAProxy si la charge dépasse 85 % au moins 2 fois. Le script stocke les occurrences dans un fichier temporaire.

Script Bash

#!/bin/bash

# Chemin du fichier temporaire pour stocker les occurrences
POOL="rbd"
# 1. Obtenir les ID des images actives
ACTIVE_IDS=$(rbd ls -p "$POOL" --format json | jq -r '.[]' | while read -r img; do
rbd info "$POOL/$img" --format json | jq -r '.block_name_prefix' | cut -d'.' -f2
done)
# 2. Lister tous les objets du pool
rados -p "$POOL" ls > /tmp/all_rbd_objects.txt