Skip to content

Instantly share code, notes, and snippets.

@undying
undying / bash_trap.sh
Last active March 28, 2025 08:40
Function wrapper for trap in Bash. It works almost like "defer" in Golang, allowing you to append multiple functions that will be called on a specific event.
function set_trap(){
local function_name="${1}"
local signal_name="${2}"
local current_trap
local current_code
[[ -z "${function_name}" || -z "${signal_name}" ]] && return 1
current_trap=$(trap -p "${signal_name}")
@undying
undying / Pytorch.Dockerfile
Created September 26, 2020 13:44
Dockerfile to build pytorch with AMD support
FROM ubuntu:18.04
RUN set -x \
&& apt-get update \
&& apt-get install \
-y \
--no-install-recommends \
--no-install-suggests \
ca-certificates \