Skip to content

Instantly share code, notes, and snippets.

View nicolargo's full-sized avatar

Nicolas Hennion nicolargo

View GitHub Profile
@nicolargo
nicolargo / gist:c90ae7e9f35657ec0b51575e2c68667c
Created May 17, 2026 10:05
Glances Virsh fix security issue
#
# Fix for GHSA-v5r2-qh84-fjx5 / Command Injection via KVM/QEMU VM Domain Names
#
# Applies to: glances/plugins/vms/engines/virsh.py (develop branch, 4.x line)
# Auto-forwarded to: develop-v5
#
# Strategy: replace f-string interpolation + secure_popen() with subprocess.run()
# and an explicit argv list for the two call sites that interpolate the
# attacker-controllable `domain` value. The other call sites in this file
# (update_version, update_domains) use static commands and are not touched, to
@nicolargo
nicolargo / vpa-report.sh
Last active April 30, 2026 11:21
A simple VPA report shell script
#!/usr/bin/env bash
# =============================================================================
# vpa-report.sh
# Display VPA recommendations alongside currently configured resource values.
#
# Columns:
# CURRENT : CPU req / Mem req / Mem limit (from Deployment or StatefulSet spec)
# VPA : CPU req / Mem req / Mem limit suggestion (JVM-aware)
# JVM HEAP : detected heap config
#
@nicolargo
nicolargo / glances_foo.py
Last active May 2, 2025 09:16
Glances plugin template
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#
"""Foo plugin (based on diskIO plugin)."""
@nicolargo
nicolargo / gist:00e6c5b9e9267ff9eb290ade3d093501
Last active March 2, 2025 18:48
Reduce power consuption of my Dell XPS 9530 laptop on Ubuntu 24.04 LTS
Before configuration, consumption is ~ 20 Watts (use powertop)
Configuration, install the Tlp software:
sudo apt instal tlp
then create (or edit by addind the line echo line), the /etc/rc.local file:
#!/bin/sh -e
@nicolargo
nicolargo / gist:4a8e88b91c6ee814d8e11246587f4311
Created January 25, 2025 10:33
Create a simple memory leak in Python (only for test purpose)
import time
# Leak 1000 bytes every 1 second
leak_size_byte = 1000
leak_freq_sec = 1
class LeakyObject:
def __init__(self, id):
self.id = id
self.data = "X" * leak_size_byte
@nicolargo
nicolargo / gist:627f31c1095a77db5dd9120904904b8e
Created April 17, 2024 11:22
OpenTelemetry Hands-on-labs
DevoXX Paris 2024 Labs
======================
By MATTHIAS HAEUSSLER - https://twitter.com/@maeddes
"This lab is made for developers seeking a pragmatic understanding of OpenTelemetry's immediate benefits.
Walk away with practical skills that can be implemented right away in your projects, and elevate your
observability game in just 180 minutes."
cat /sys/class/drm/card0/device/pp_od_clk_voltage
cat /sys/kernel/debug/dri/0/amdgpu_pm_info
cat /sys/class/drm/card0/device/gpu_busy_percent
cat /sys/class/drm/card0/device/pp_dpm_sclk
cat /sys/class/drm/card0/device/hwmon/hwmon*/temp1_input
cat /sys/class/drm/card0/device/pp_dpm_mclk
cat /sys/class/drm/card0/device/mem_info_vram_used
cat /sys/class/drm/card0/device/mem_info_vram_total
@nicolargo
nicolargo / gist:7e7a455a6d86bcd027d68a7347c36380
Created April 30, 2023 08:44
Change automaticaly the Linux keyboard layout on my laptop when an external keyboard is connected/disconnected
Plug your external keyboard and enter the following command line to get the vendor/product id:
# lsusb
Bus 002 Device 065: ID 05ac:024f Apple, Inc. Aluminium Keyboard (ANSI)
For example, my Keychron keyboard is detected as an Apple keyboard with vendorid=05ac and productid=024f
Create the following scripts:
# sudo vi /etc/udev/rules.d/10-keyboard-plug.sh
@nicolargo
nicolargo / gist:b9e6bd079b07fe64cb8c9b798a219cb0
Created October 22, 2022 13:03
Test podman (Python API)
#!/usr/bin/env python
"""Demonstrate PodmanClient."""
import podman
# Provide a URI path for the libpod service. In libpod, the URI can be a unix
# domain socket(UDS) or TCP. The TCP connection has not been implemented in this
# package yet.
uri = "unix:///run/user/1000/podman/podman.sock"
@nicolargo
nicolargo / compress-value.py
Last active October 26, 2021 06:43
Compress list of float (precision 0.01)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Timestamp compression test bed
#
#
import sys
import array