Skip to content

Instantly share code, notes, and snippets.

View nicolargo's full-sized avatar

Nicolas Hennion nicolargo

View GitHub Profile
@nicolargo
nicolargo / gist:00e6c5b9e9267ff9eb290ade3d093501
Created April 28, 2024 07:00
Reduce power consuption of my Dell XPS 9530 laptop on Ubuntu 24.04 LTS
Before configuration, consumption is ~ 20 Watts
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: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 / gist:1fd5aa8833c03c9bbe2cf1a93cd364d9
Last active June 11, 2021 07:19
Install Minikube, Kubernetes and Helm on Ubuntu
Install minikube
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ chmod +x minikube
$ sudo install minikube /usr/local/bin/
Get the minikube version
$ minikube version
minikube version: v1.20.0
@nicolargo
nicolargo / gist:5e8c0c1f623ae14d01fed86bc2a3cbee
Created October 12, 2017 06:41
Install a XMPP stack: Prosody + Nginx + Jsxc on Ubuntu
Prosody is available as a Docker image (https://github.com/prosody/prosody-docker)
Pull it:
docker pull prosody/prosody
and start it (https://github.com/prosody/prosody-docker):
docker run -d -p 5280:5280 -e LOCAL=nicolargo -e DOMAIN=nicolargo.com -e PASSWORD=mdp prosody/prosody:latest
44e501c0e6454b6b5c316fe49b1506486b14a1ccd7566363811a7d0c094ec572
@nicolargo
nicolargo / glances_foo.py
Created March 5, 2017 16:02
Glances plugin template
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# Copyright (C) 2017 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
import os
POWER_SUPPLY_PATH = "/sys/class/power_supply"
_DEFAULT = object()
def open_binary(fname, **kwargs):
return open(fname, "rb", **kwargs)
def cat(fname, fallback=_DEFAULT, binary=True):
from datetime import datetime
import subprocess
import os
def foo(c):
fnull = open(os.devnull, 'w')
d1 = datetime.now()
subprocess.check_call(c, stdout=fnull, stderr=fnull, close_fds=True)
return (datetime.now() - d1).total_seconds()