Skip to content

Instantly share code, notes, and snippets.

View luzfcb's full-sized avatar

Fábio C. Barrionuevo da Luz luzfcb

View GitHub Profile
@luzfcb
luzfcb / 0_install_extra_packages.sh
Created July 1, 2024 01:30
install extra debian packages on the docker-steam-headless . Simple create a extra_packages.txt on Download directory with the name of the packages
#!/bin/bash
# Define file and directory paths
BASE_HOME_DIR="/home/default"
PACKAGE_LIST="${BASE_HOME_DIR}/Downloads/extra_packages.txt"
TEMP_DIR="/tmp/extra_packages"
DEST_DIR="${BASE_HOME_DIR}/Downloads/extra_packages"
LOG_FILE="$TEMP_DIR/download.log"
# Check if the package list file exists
@luzfcb
luzfcb / Paw_Patrol_On_A_Roll_steam_linux.md
Created June 14, 2024 13:53
Paw Patrol: On A Roll! fixes for Steam, SteamDeck, Wine, Proton, ProtonGE, Language, Linux
@luzfcb
luzfcb / open_rgb.service
Created June 5, 2024 20:32
systemd open_rgb.service . Load an OpenRGB profile when the computer has a cold boot or wakeup from suspension mode.
# /etc/systemd/system/open_rgb.service
# sudo systemctl enable open_rgb.service
# sudo systemctl start open_rgb.service
[Unit]
Description=OpenRGB control
After=multi-user.target suspend.target
[Service]
Type=oneshot
ExecStart=/usr/bin/openrgb --localconfig -p <profile_name>.orp
@luzfcb
luzfcb / gist:51aecde6bf303170c1d25a70ec94e7b7
Last active May 7, 2024 16:15
netdata docker start without telemetry
mkdir -p /etc/netdata/
touch /etc/netdata/.opt-out-from-anonymous-statistics
docker run -d --name=netdata \
--pid=host \
--network=host \
-v /etc/netdata:/etc/netdata \
-v netdatalib:/var/lib/netdata \
-v netdatacache:/var/cache/netdata \
-v /etc/passwd:/host/etc/passwd:ro \

show me 20 different uses of the tee function of the python itertools library

Chat GPT:

Certainly! The tee function in the Python itertools library is used to create independent iterators from a single iterable. Here are 20 different uses of the tee function:

  1. Splitting an iterable into two independent iterators:
from itertools import tee
@luzfcb
luzfcb / nvme_temps
Created October 12, 2022 18:06
extract nvme ssd temperatures
#!/usr/bin/env python3
import sys
import getpass
import json
from io import StringIO
try:
import sh
except ImportError:
print("Please, install the sh library http://amoffat.github.io/sh/#installation")
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
postgres_ready() {
python << END
import sys
@luzfcb
luzfcb / invalidate_cached_property.py
Last active October 7, 2022 00:31
Invalidate cached_property
from functools import cached_property as functools_cached_property
try:
from django.utils.functional import cached_property as django_cached_property
except ImportError:
cached_property_classes = (
functools_cached_property,
)
else:
cached_property_classes = (
@luzfcb
luzfcb / drf_utils.py
Created April 29, 2022 13:26 — forked from twidi/drf_utils.py
Make Django Rest Framework correctly handle Django ValidationError raised in the save method of a model
"""
Sometimes in your Django model you want to raise a ``ValidationError`` in the ``save`` method, for
some reason.
This exception is not managed by Django Rest Framework because it occurs after its validation
process. So at the end, you'll have a 500.
Correcting this is as simple as overriding the exception handler, by converting the Django
``ValidationError`` to a DRF one.
"""
from django.core.exceptions import ValidationError as DjangoValidationError
repos:
- repo: https://github.com/browniebroke/django-codemod
# django-codemod is a tool to automatically
# fix Django deprecations.
# Any tag/version (>=1.10.2):
# https://github.com/browniebroke/django-codemod/tags
#
# Automatic execution of this hook has been disabled
# because it is a bit slow but its configuration is
# kept here so it can be easily run: