Skip to content

Instantly share code, notes, and snippets.

View WoozyMasta's full-sized avatar
👽
gotcha

Maxim Levchenko WoozyMasta

👽
gotcha
View GitHub Profile
@WoozyMasta
WoozyMasta / curl-jq-pagination.sh
Created November 20, 2024 10:03
Example curl and jq get data with pagination
#!/usr/bin/env bash
set -euo pipefail
: "${SOURCE_GITLAB_URL:?}"
: "${SOURCE_GITLAB_TOKEN:?}"
: "${TARGET_GITLAB_URL:?}"
: "${TARGET_GITLAB_TOKEN:?}"
# Make curl request to GitLab API
api() {
@WoozyMasta
WoozyMasta / get-telegram-sticers.sh
Last active October 18, 2024 07:25
Download telegram stickers and convert to PNG/GIF with optimizations
#!/usr/bin/env bash
# Download telegram stickers and convert to PNG/GIF
#
# Dependecies:
# - jq, curl
# - https://www.ffmpeg.org/
# - https://pngquant.org/
# - http://www.lcdf.org/gifsicle/
# - https://github.com/ed-asriyan/lottie-converter
@WoozyMasta
WoozyMasta / README.md
Last active March 12, 2024 12:25
DayZ Linux Server watchdog

DayZ Linux Server watchdog

This DayZ Watchdog script to check server availability

With the release of DayZ 1.24, a server for Linux appeared, this is undoubtedly very cool, but the implementation was in an experimental state for a very long time, which is why some problems crop up when trying to run modified community servers.

At the time of writing, there was a problem with the scheduled restart of the modified server based on an event from messages.xml. Details at https://feedback.bistudio.com/T179734

Important

These are instructions for a non-system user; for a root user you can adapt them yourself if necessary

@WoozyMasta
WoozyMasta / nginx.conf
Created May 25, 2023 08:37
Openresty prometheus metrics
init_worker_by_lua_block {
prometheus = require("prometheus").init("prometheus_metrics")
metric_requests = prometheus:counter(
"nginx_http_requests_total",
"Number of HTTP requests",
{"host", "status"}
)
metric_latency = prometheus:histogram(
"nginx_http_request_duration_seconds",
@WoozyMasta
WoozyMasta / README.md
Last active May 23, 2023 20:02
Script for Nginx/Openresty to restore up-to-date source IP addresses of visitors from Cloudflare

Renew source IP addresses from Cloudflare

Script for Nginx/Openresty to restore up-to-date source IP addresses of visitors from Cloudflare

Installation

Set params like NGINX_BIN_PATH and CLOUDFLARE_CONFIG_PATH

echo "NGINX_BIN_PATH=/usr/bin/openresty" > /etc/cloudflare-real-ip-update.env
@WoozyMasta
WoozyMasta / registry-config-ds.yaml
Last active November 24, 2022 13:02
Create and update multiple container registry cache proxies in CRI-O with Daemonset without direct access to k8s node
apiVersion: v1
kind: ConfigMap
metadata:
name: registry-config
namespace: kube-system
data:
unqualified-search-registries.conf: |
unqualified-search-registries = [
"docker.io",
"quay.io",
@WoozyMasta
WoozyMasta / nginx-ssh-ssl.conf
Created August 3, 2022 15:07
SSL and SSH on the same port in Nginx
stream {
upstream ssh {
server 127.0.0.1:22;
}
upstream web {
server 127.0.0.1:443;
}
map $ssl_preread_protocol $upstream {
@WoozyMasta
WoozyMasta / Dockerfile
Created July 12, 2022 02:49
An example of building a Python application into a self-contained statically linked binary and packaging it into a container image based on scratch
FROM docker.io/python:3.9-bullseye AS build
WORKDIR "/app"
# Install dependecies
# hadolint ignore=DL3008,DL3013
RUN set -eux && \
apt-get update; \
apt-get install --no-install-recommends -y \
python3-dev build-essential patchelf upx; \
apt-get clean; \
@WoozyMasta
WoozyMasta / nexus-proxy-caches-revalidate.sh
Created June 16, 2022 09:41
Script for rebuild indexes and invalidate cache in Sonatype nexus 3 npm|nuget|pypi|maven proxy
#!/usr/bin/env bash
#
# Script for rebuild indexes and invalidate cache in NPM proxy repositories.
# Configuration can load from hide file with same name as script
# Example: this-srcipt.sh load config from ./.this-srcipt
#
# Copyright 2020 WoozyMasta <woozy.masta@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@WoozyMasta
WoozyMasta / wg-post-chain.sh
Last active February 14, 2023 13:13
Wireguard PostUp PostDown script
#!/usr/bin/env bash
# wg-post %i UP/DOWN
set -euo pipefail
: "${WG_IFACE:=${1:-wg0}}"
: "${WG_ACTION:=${2:-down}}"
: "${WG_CONF:=/etc/wireguard/$WG_IFACE.conf}"
[ -f "$WG_CONF" ] || { >&2 echo "File $WG_CONF not accessible"; exit 1; }