Skip to content

Instantly share code, notes, and snippets.

View dcasati's full-sized avatar

Diego Casati dcasati

View GitHub Profile
@dcasati
dcasati / podman
Created April 30, 2024 20:27
run podman in a pod
# to run podman in a pod
# create a priviledge pod
cat <<EOF | kubectl apply -f -
kind: Pod
apiVersion: v1
metadata:
name: adcirc-debug
spec:
containers:
@dcasati
dcasati / run.sh
Last active September 25, 2023 22:30
torchrun
#!/usr/bin/env bash
set -x
export TORCH_CPP_LOG_LEVEL=INFO
export TORCH_DISTRIBUTED_DEBUG=DETAIL
export LOGLEVEL=DEBUG
export NCCL_DEBUG=warn
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:/usr/local/nccl-rdma-sharp-plugins/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libnccl.so
export NCCL_IB_PCI_RELAXED_ORDERING=1
@dcasati
dcasati / azure firewall query - deny
Created April 14, 2023 00:23
azure firewall query to show packets that were denied
AzureDiagnostics
| where ResourceType == "AZUREFIREWALLS"
| extend
proto = extract(@"^([A-Z]+) ",1,msg_s)
,src_host = extract(@"request from ([\d\.]*)",1,msg_s)
,src_port = extract(@"request from [\d\.]*:(\d+)",1,msg_s)
,dest_host = extract(@" to ([-\w\.]+)(:|\. |\.$)",1,msg_s)
,dest_port = extract(@" to [-\w\.]+:(\d+)",1,msg_s)
,action = iif(
msg_s has "was denied"
@dcasati
dcasati / gist:25be5997183b4e362d1eb729b384a13b
Created February 7, 2023 21:43
removing AppleDouble files and extended attributes from a tarbal
# when creating a tarball on macOS you might want to exclude the
# AppleDouble files and xattr in your tarball
#
# here is an example:
tar --disable-copyfile --no-xattrs -cvzf capsh-0.1.1.tar.gz .
# These steps are known to work on a rpi1,2 and 3.
# tested with the Samsung SCX-3400 are needed
sudo apt install avahi-daemon cups printer-driver-splix
sudo usermod -a -G lpadmin pi
sudo cupsctl --remote-any
# enable the daemons
sudo systemctl enable cups
sudo systemctl enable avahi-daemon
#remove the azure cli if installed via apt:
sudo apt remove azure-cli
#install the azure cli with pip:
sudo python3 -m pip install msrest==0.6.21
sudo python3 -m pip install azure.cli
tested on Fedora release 34 (Thirty Four):
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo"
# Use these steps to clear out Github's commit history.
# Useful when moving a repo from private to public
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D main # Deletes the main branch
git branch -m main # Rename the current branch to main
git push -f origin main # Force push master branch to github
git gc --aggressive --prune=all # remove the old files
@dcasati
dcasati / batch remove azure service principals
Last active January 11, 2022 22:38
batch remove Service Principals not being used
az_rm_sp()(az ad sp list --show-mine -o json --query "[?contains(displayName, '$1')]" | jq -r '.[] | .appId' | xargs -P 4 -n 12 -I % az ad sp delete --id %)
example:
az_rm_sp azure-cli
@dcasati
dcasati / renameworkspace.py
Last active May 27, 2021 04:30 — forked from fahrstuhl/renameworkspace.py
Renaming i3 workspaces with https://github.com/acrisci/i3ipc-python while keeping the <number> <letter> prefix for keyboard navigation.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# renameworkspace.py - Renaming i3 workspaces with https://github.com/acrisci/i3ipc-python while keeping the <number>: <letter> prefix for keyboard navigation.
# Written in 2017 by Fahrstuhl
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
import i3ipc