Skip to content

Instantly share code, notes, and snippets.

@un-def
un-def / a100-80gb-sxm-ib-cloud-hypervisor.xml
Last active December 11, 2025 07:58
Crusoe Cloud NCCL topology files
<system version="1">
<cpu numaid="0" affinity="00000000,0000ffff,ffffffff" arch="x86_64" vendor="GenuineIntel" familyid="6" modelid="106">
<pci busid="ffff:ff:01.0" class="0x060400" vendor="0xffff" device="0xffff" subsystem_vendor="0xffff" subsystem_device="0xffff" link_speed="16.0 GT/s PCIe" link_width="16"> <!-- Switch 0 begins -->
<pci busid="0002:00:01.0" class="0x030200" vendor="0x10de" device="0x20b2" subsystem_vendor="0x10de" subsystem_device="0x1463" link_speed="16.0 GT/s PCIe" link_width="16"/> <!-- GPU 0 -->
<pci busid="0002:00:02.0" class="0x030200" vendor="0x10de" device="0x20b2" subsystem_vendor="0x10de" subsystem_device="0x1463" link_speed="16.0 GT/s PCIe" link_width="16"/> <!-- GPU 1 -->
<pci busid="0002:00:09.0" class="0x020000" vendor="0x15b3" device="0x1021" subsystem_vendor="0x15b3" subsystem_device="0x0023" link_speed="16.0 GT/s PCIe" link_width="16"/> <!-- NIC 0 -->
<pci busid="0002:00:0a.0" class="0x020000" vendor="0x15b3" device="0x1021" subsystem_
@un-def
un-def / kbdl.sh
Last active July 18, 2024 12:33
Multi–layout Switcher based on kbdd
#!/bin/sh
### Constants
# the index of the first layout in the primary layer
PRIMARY_LAYER=0
# the index of the first and only layout in the secondary layer
SECONDARY_LAYER=2
### Functions
@un-def
un-def / i3pws.py
Last active July 15, 2024 21:02
i3 persistent workspaces
from __future__ import annotations
import argparse
import json
import subprocess
from typing import Callable, Iterable, Iterator, TypedDict
class Workspace(TypedDict):
name: str
@un-def
un-def / sqlite.lua
Created May 23, 2024 06:12
LuaJIT FFI SQLite C Interface Demo
local sql = arg[1]
if not sql then
print(('usage: %s SQL'):format(arg[0]))
os.exit()
end
local ffi = require('ffiex')
local lib = ffi.load('sqlite3')
@un-def
un-def / nginx.conf
Created May 17, 2024 17:50
Nginx fix Location header on redirects behind reverse proxy
http {
map $http_x_forwarded_proto=$http_x_forwarded_port $redirect_port {
http=80 '';
https=443 '';
default :$http_x_forwarded_port;
}
server {
listen 8080;
@un-def
un-def / switch-sink.bash
Created January 27, 2022 21:15
Switch PulseAudio sinks
#!/usr/bin/env bash
die() {
notify-send "${NOTIFICATION_SUMMARY}" "${1}" -i audio-volume-muted -t 3000
exit 1
}
config_path="${XDG_CONFIG_HOME:-$HOME/.config}/switch-sink.conf.bash"
[[ -f ${config_path} ]] || die 'Config not found'
# shellcheck disable=SC1090
@un-def
un-def / switch-sink.sh
Created January 12, 2022 11:30
Switch between two PulseAudio sinks
#!/bin/sh
INTEGRATED='pci-0000_0c_00.4'
VIDEOCARD='pci-0000_0a_00.1'
TRAY_APP='volumeicon'
NOTIFICATION_SUMMARY='Audio Output'
die() {
@un-def
un-def / Dockerfile
Last active December 23, 2021 09:31
Python Docker multistage build template
ARG python_version
FROM python:${python_version}-alpine AS base
FROM base AS builder
COPY requirements.txt /tmp/
RUN pip install --target=/tmp/build --no-deps -r /tmp/requirements.txt
FROM base
ARG python_version
WORKDIR /opt/project/
/* @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); */
/* hide the native tabs */
#main-window:not([privatebrowsingmode]) #TabsToolbar {
visibility: collapse;
}
/* hide the sidebar header */
local tcp_sock_mt = getmetatable(ngx.socket.tcp())
local udp_sock_mt = getmetatable(ngx.socket.udp())
local is_socket_object = function(obj)
local obj_mt = getmetatable(obj)
return obj_mt == tcp_sock_mt or obj_mt == udp_sock_mt
end
--------