Skip to content

Instantly share code, notes, and snippets.

View cofob's full-sized avatar
🏳️‍🌈

Egor Ternovoi cofob

🏳️‍🌈
View GitHub Profile
@cofob
cofob / 0_README.md
Last active July 24, 2023 09:06
Taskiq routing support

This code does roughly the same thing as this example, but in a more optimized and flexible way, because:

  1. it does not open channels for each node on both client and server. In the example there were 3 queues and each vorker would open all 3 channels that it never used. This is achieved by separating the brokers into Listener and Sender (Routed).
  2. it supports dynamic sending to the specific node, the code from the example only supported predefined queues.
  3. Added more convenient aliases to remove the duplication of with_broker(broker).with_labels(node=node_name) on each task call.

It also breaks compatibility with taskiq_aio_pika a bit, since it uses a different Exchange type and uses the node name as routing_key.

But despite the pros it doesn't support some taskiq features and is more complex to use. For example worker will not be able to call context.requeue because listener broker has no write channel.

The startup is almost the

__version__ = (1, 0, 1)
#
# █░░ █ ▀█▀ █▀▀
# █▄▄ █ ░█░ ██▄
#
# © Copyright 2023
#
# Licensed under the GNU GPLv3
# https://www.gnu.org/licenses/agpl-3.0.html

Настройка GRE

GRE (Generic Routing Encapsulation) туннели позволяют оборачивать пакеты одной сети внутри пакетов другой сети. Вот пошаговая инструкция по созданию GRE туннеля на Linux Ubuntu между двумя серверами (1.1.1.1 и 2.2.2.2) с использованием внутреннего адреса из подсети 10.100.0.1/24.

Сервер 1.1.1.1

  1. Откройте терминал и введите следующую команду для создания GRE туннеля:

    sudo ip tunnel add gre1 mode gre remote 2.2.2.2 local 1.1.1.1 ttl 255
__version__ = (1, 0, 0)
# meta developer: @cofob
from telethon.tl.types import Message
import logging
from .. import loader, utils # noqa
logger = logging.getLogger(__name__)
__version__ = (2, 0, 0)
import contextlib
# meta developer: @cofob
# meta banner: https://i.imgur.com/H1vPM6U.jpg
from telethon.tl.types import Message
import requests
import logging
@cofob
cofob / yadown.py
Last active January 6, 2024 11:24
__version__ = (2, 0, 0)
# meta developer: @cofob
# requires: git+https://github.com/MarshalX/yandex-music-api@dev eyed3
# meta desc: Module for downloading music from Yandex Music
import logging
import os
import eyed3
/// Calculate SHA256 HMAC
fn hmac(secret: &[u8], data: &[u8]) -> [u8; 32] {
let mut h = HMAC::new(secret);
h.update(data);
h.finalize()
}
#[derive(Serialize, Deserialize, Debug)]
struct InitDataParams {
auth_date: u64,
@cofob
cofob / WebApp.json
Last active October 27, 2022 20:30
{
"initData": "",
"initDataUnsafe": {},
"version": "6.2",
"platform": "android",
"colorScheme": "light",
"themeParams": {
"bg_color": "#ffffff",
"secondary_bg_color": "#f0f0f0",
"text_color": "#222222",
{
description = "InTape backend";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, ... }:
pkgs.stdenv.mkDerivation {
pname = "requirements";
version = "0.1.0";
src = ./.;
buildInputs = [ pkgs.python3Packages.poetry ];
phases = [ "installPhase" ];
installPhase = ''
cd $src
export XDG_CONFIG_HOME=/tmp/
poetry config virtualenvs.create false