Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar
🎯
Looking for a job

Vladislav Yarmak Snawoot

🎯
Looking for a job
View GitHub Profile

Poor Man's Global Traffic Manager

Sometimes we need to add redundancy to some service or server which happen to be a public-facing entry point of our infrastructure. For example, imagine we want to add a high availability pair for a load balancer which sits on the edge of network and forwards traffic to alive backend servers.

                                             ┌─────────────┐
                                             │             │
                                      ┌─────►│  Backend 1  │
                                      │      │             │
                                      │      └─────────────┘
@Snawoot
Snawoot / remote.conf
Created July 10, 2022 13:08
syslog-ng config for nice remote logging. place it into /etc/syslog-ng/conf.d/remote.conf
template remote {
template("${ISODATE} ${LEVEL} ${MSGHDR}${MESSAGE}\n");
};
destination d_sorted {
file(
"/var/log/remote/${PROGRAM}/${C_YEAR}_${C_MONTH}_${C_DAY}_${C_HOUR}.log"
create-dirs(yes)
template(remote)
time_zone("UTC")
@Snawoot
Snawoot / tanos.sh
Last active August 23, 2022 04:22
Halves old logs
#!/bin/bash
set -euo pipefail
treshold=${HIGH_WATER_PCT:-85}
cleanup_dir=${DIR:-/var/log/remote/}
fraction=${DELETE_FRACTION:-0.5}
(
if ! flock -n 9 ; then
let genre_re = /Жанр:.*(adventure|приключен|quest|квест|пошагов|TBS|turn-based)/iu;
let neg_genre_re = /Жанр:.*(шутер|shooter|FPS|аниме|симулятор|ходь|RPG|ролев|платформер|platform|текстов|хоррор|horror|Survival|выжива|инди|indie|поиск предметов|аркада|arcade|Sandbox|песочница|музыка)/iu;
let neg_title_re = /(remaster|reloaded|в разработке|\[(Air|Flash)\]|\bags\b)/iu;
let year_re = /Год.*:.*(\d{4}).*/iu;
(function (elem) {
if (elem.Deleted == 1) return
if (elem.Title.match(neg_title_re)) return
let stripped = strip_bbcode(elem.Content)
if (stripped.match(neg_genre_re)) return
@Snawoot
Snawoot / discardd.py
Last active June 27, 2021 18:56
TCP discard daemon
#!/usr/bin/env python3
import asyncio
class EchoServerProtocol(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
def data_received(self, data):
pass
@Snawoot
Snawoot / rutracker-topic-watch.gs
Created June 14, 2021 22:06
Скрипт Google App Script для получения уведомлений о новых сообщений в темах на рутрекере (rutracker.org) на почту
const TRACKED_TOPICS = [
6027310,
6046402,
5887367,
5440705,
5591249,
];
const CONTENT_CHARSET = 'cp1251';
const TOPIC_URL_TMPL = 'https://rutracker.org/forum/viewtopic.php?t=%d&start=%d';
#!/usr/bin/env python3
import ssl
import http.server
import socketserver
from http import HTTPStatus
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(HTTPStatus.UNAUTHORIZED)
@Snawoot
Snawoot / appscript.json
Created March 3, 2021 17:25
Google App Script for notifying about new releases of The Expanse series
{
"timeZone": "Europe/Bucharest",
"dependencies": {
},
"oauthScopes": [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.send_mail"
],
name: telegram-desktop
adopt-info: telegram
icon: Telegram/Resources/art/icon512@2x.png
base: core18
grade: stable
confinement: strict
architectures:
- build-on: amd64
@Snawoot
Snawoot / password.txt
Last active November 4, 2025 13:58 — forked from gabonator/password.txt
HiSilicon IP camera root passwords
Login Password
root xmhdipc
root klv123
root xc3511
root 123456
root jvbzd
default OxhlwSG8
defaul tlJwpbo6
defaul S2fGqNFs
default tluafed