Skip to content

Instantly share code, notes, and snippets.

View zuzzas's full-sized avatar

Andrey Klimentyev zuzzas

View GitHub Profile
@zuzzas
zuzzas / configure_logind.sh
Created May 12, 2022 12:06
Testing inhibitor locks
#!/bin/bash
cat <<EOF > /etc/systemd/system/inhibit.service
[Unit]
Description=heh
After=network.target
[Service]
Type=simple
@zuzzas
zuzzas / limits.c
Created May 14, 2018 11:25
Revised snippet from prlimit(2)
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/resource.h>
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \
@zuzzas
zuzzas / purge-multi.lua
Created August 25, 2017 14:28 — forked from titpetric/purge-multi.lua
Delete NGINX cached items with a PURGE with wildcard support
-- Tit Petric, Monotek d.o.o., Tue 03 Jan 2017 06:54:56 PM CET
--
-- Delete nginx cached assets with a PURGE request against an endpoint
-- supports extended regular expression PURGE requests (/upload/.*)
--
function file_exists(name)
local f = io.open(name, "r")
if f~=nil then io.close(f) return true else return false end
end
#!/bin/bash
# This script allows you to backup a single volume from a container
# Data in given volume is saved in the current directory in a tar archive.
CONTAINER_NAME=$1
VOLUME_NAME=$2
VOLUME_NAME_SANITIZED=$(echo $VOLUME_NAME | sed s#/#_#2g)
usage() {
echo "Usage: $0 [container name] [volume name]"
exit 1
@zuzzas
zuzzas / volume_backup.sh
Created July 5, 2017 14:21
Docker volume backup
#!/bin/bash
# This script allows you to backup a single volume from a container
# Data in given volume is saved in the current directory in a tar archive.
CONTAINER_NAME=$1
VOLUME_NAME=$2
usage() {
echo "Usage: $0 [container name] [volume name]"
exit 1
}
@zuzzas
zuzzas / debian-preseeded-iso.sh
Last active July 31, 2023 09:07
Create Debian netinstall iso with preseed file
set -e
set -u
# hat-tips:
# - http://codeghar.wordpress.com/2011/12/14/automated-customized-debian-installation-using-preseed/
# - the gist
# required packages (apt-get install)
# xorriso
@zuzzas
zuzzas / hfsc-shape.sh
Created March 18, 2016 10:19 — forked from bradoaks/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@echo off
set /p HOST="Enter IP address or FQDN: "
:while
set SAVESTAMP=%DATE:/=-%@%TIME::=-%
set SAVESTAMP=%SAVESTAMP: =%
echo %SAVESTAMP%
echo Next iteration...
pathping -q 100 -n %HOST% > %SAVESTAMP%.txt
GOTO while
#!/bin/bash
for i in `seq 1 10000`
do /bin/date +%Y-%m-%d-%H-%M-%S
mtr -n -c 600 -i 1 -r 10.147.0.46 > 10.147.0.46_$(/bin/date +%Y-%m-%d-%H-%M-%S).txt
done
@zuzzas
zuzzas / gunicorn.service
Last active August 29, 2015 14:26
gunicorn systemd unit
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
PIDFile=/var/apps/gunicorn.pid
User=apps
Group=apps
WorkingDirectory=/var/apps/bans
ExecStart=/usr/local/bin/gunicorn --pid /var/apps/gunicorn.pid --bind unix:/var/apps/apps.sock wsgi:app