Skip to content

Instantly share code, notes, and snippets.

Avatar

Snawoot

  • Odessa, Ukraine
View GitHub Profile
View poor_mans_gtm.md

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 Jul 10, 2022
syslog-ng config for nice remote logging. place it into /etc/syslog-ng/conf.d/remote.conf
View 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 Aug 23, 2022
Halves old logs
View tanos.sh
#!/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
View filter.js
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 Jun 27, 2021
TCP discard daemon
View discardd.py
#!/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 Jun 14, 2021
Скрипт Google App Script для получения уведомлений о новых сообщений в темах на рутрекере (rutracker.org) на почту
View rutracker-topic-watch.gs
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';
View downgrade-digest.py
#!/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 Mar 3, 2021
Google App Script for notifying about new releases of The Expanse series
View appscript.json
{
"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"
],
View snapcraft.yaml
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 Feb 3, 2020 — forked from gabonator/password.txt
HiSilicon IP camera root passwords
View password.txt
Login Password
root xmhdipc
root klv123
root xc3511
root 123456
root jvbzd
default OxhlwSG8
defaul tlJwpbo6
defaul S2fGqNFs
default tluafed