Skip to content

Instantly share code, notes, and snippets.

@undying
undying / count_nginx_errors.awk
Created June 11, 2025 15:57
Script to count nginx errors by their types
#!/usr/bin/awk -f
BEGIN {
ERROR_USERID_SHORT = 0
ERROR_LIMIT_REQ = 1
ERROR_RECV = 2
ERROR_UPSTREAM_CLOSED = 3
ERROR_OPEN_FILE = 4
ERROR_SSL_HANDSHAKE = 5
ERROR_FILE_NOT_FOUND = 6
@undying
undying / string_to_bool.sh
Created May 21, 2025 15:23
Transforms string into boolean value
function s_to_bool(){
local s="${1}"
[[ -n "${s}" ]] || return 1
case "${s}" in
[nN][oO]|[fF][aA][lL][sS][eE]|0)
return 1;;
*) return 0;;
esac
}
@undying
undying / run_one.sh
Created May 5, 2025 11:48
Bash wrapper to run only one command in a time
#! /bin/bash
ENV_FILE=/etc/container_env
set -a
source "${ENV_FILE}"
set +a
function set_trap(){
local function_name="${1}"
@undying
undying / image_version_bump.sh
Created April 25, 2025 20:36
Script to bump image versions in docker-compose.yml file
#! /bin/bash
VERSION_TYPES=(
# 29
'^[0-9]{1,}$'
# 29-fpm
'^[0-9]{1,}-[a-z]{1,}$'
# 2024040105
'^[0-9]{10}$'
# 4.0.10-develop
@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 \