Skip to content

Instantly share code, notes, and snippets.

View lucaspar's full-sized avatar

Lucas Parzianello lucaspar

  • University of Notre Dame
View GitHub Profile
@lucaspar
lucaspar / flock_example.py
Last active September 6, 2025 02:06 — forked from jirihnidek/flock_example.py
Python file locking using `fcntl.flock`
#! /usr/bin/env python
"""
Example of using fcntl.flock for locking file. Some code inspired by filelock module.
"""
import fcntl
import os
import time
@lucaspar
lucaspar / rlock-demo.py
Last active August 6, 2025 14:00
Demo of `multiprocessing.RLock` with context managers
# To run this demo:
# uv run https://gist.github.com/lucaspar/9560f11cfefdb19375c22b57f2103c76
# /// script
# requires-python = ">=3.13"
# dependencies = ["rich"]
# ///
import multiprocessing
import time
@lucaspar
lucaspar / install-nvidia-rhel9.sh
Last active July 3, 2025 13:46
Install NVIDIA drivers and container toolkit on RHEL 9.
#!/usr/bin/env bash
# This script installs NVIDIA drivers and container toolkit on RHEL 9.
# It should be safe to run it multiple times: steps are skipped when not needed.
# This is an interactive script: system and services restarts are prompted to the user.
# Source:
# https://gist.github.com/lucaspar/def9198eabc110345c746806e0b90f38/
set -euo pipefail
@lucaspar
lucaspar / dckr-volumes
Last active December 10, 2024 15:09
Lists dangling docker volumes and their sizes
#!/usr/bin/env bash
# Usage: dckr-volumes [OPTIONS]
# Lists dangling Docker volumes and their sizes.
# Options:
# -h, --help Shows this help message and exit
# -a, --all Lists all Docker volumes and their sizes, not only dangling ones
# --no-header Hides the header
#
set -euo pipefail
@lucaspar
lucaspar / inspirobot.sh
Last active June 22, 2024 02:29
Inspirational images paired with questionable advice on the command line. Powered by https://inspirobot.me/
# Returns success (0) if the argument exists as a program, alias, or a function.
function exists() {
# if no argument, show usage and return false
if [ -z "${1}" ]; then
echo "Usage: exists <program>"
return 1
fi
command -v "${1}" >/dev/null 2>&1
}
@lucaspar
lucaspar / wip.sh
Last active April 30, 2025 22:33
"Work in Progress" | A git helper to save partial work
# Source: https://gist.github.com/lucaspar/c6ed7e5654887beeb703b163d9b57712
# Add this function to your .bashrc, then source it: `source ~/.bashrc` or restart the terminal.
# Helper function for submitting working changes into version control and avoid loss of work.
# Work in Progress (`wip`) will create a temporary commit with your unstaged changes and a
# generic message. When run subsequently and within 24h of the last "wip" commit, it amends
# the last commit to prevent cluttering the commit history. Otherwise it will create a new "wip"
# commit. After a few hours of work, consider amending the "wip" commit with a proper message.
# Usage:
# wip [options] [file_a path_b file_c ...]
@lucaspar
lucaspar / slack-notify
Last active July 12, 2024 19:59
Slack notification script
#!/usr/bin/env bash
# Issues notifications on a Slack channel.
#
# >>> Don't forget to set SLACK_WEBHOOK_URL_DEFAULT to a valid URL <<<
#
# Usage: slack-notify "leave the gun. take the cannoli"
# Source: https://gist.github.com/lucaspar/64c9cf35756d1892e749c1bd735aa0fe
set -euo pipefail
# Slack Notifications
@lucaspar
lucaspar / heimdall-style.css
Created July 20, 2023 15:18
Heimdall Style
/* Paste these lines in Settings > Advanced > Custom CSS */
/* ================ */
/* generic elements */
body {
background-color: rgb(16, 16, 16);
color: rgb(198, 198, 198);
/* font-family: monospace; */
line-height: 1.8;
}
@lucaspar
lucaspar / waste_my_ram.py
Created July 14, 2023 20:17
Progressively allocates all memory in a system
"""You probably don't want to run this.
Source: https://stackoverflow.com/a/66109163/2848528
"""
import logging
import secrets
from typing import Optional
from humanfriendly import format_size
@lucaspar
lucaspar / Debugging.md
Created June 24, 2023 21:39
Debugging in containers

Debugging in containers

Tired of "command not found" - these lines will install commonly used tools to debug networking, read logs, and other things.

Start a shell as root inside the container

CONTAINER_KEYWORD="spark"
CONTAINER_NAME=$(docker ps | grep -i "${CONTAINER_KEYWORD}" | head -n 1 | awk '{print $NF}')
echo "CONTAINER_NAME: ${CONTAINER_NAME}"