Skip to content

Instantly share code, notes, and snippets.

View Hammer2900's full-sized avatar
🌲
___

Yevhen Ts. Hammer2900

🌲
___
View GitHub Profile
#Принудительно меняем раскладу для Konsole и kitty
#Для телеграм меняем на Русский
#Для всего остального меняю на английский
from i3ipc import Connection, Event
import subprocess,os
@ruanbekker
ruanbekker / k3s-demo-with-cluster.md
Created September 27, 2019 15:29
kubernetes demo with cluster mode on k3s

Install k3s on master node:

curl -sfL https://get.k3s.io | sh -
# get token
cat /var/lib/rancher/k3s/server/node-token

Install k3s on worker nodes as agents:

@tomdottom
tomdottom / 1-distributed-rate-limiting-of-message-queues.md
Last active May 19, 2022 13:27
Distributed rate limiting of multiple tasks queues (RabbitMQ) and the Kombu package

Basic task processing with distributed rate limiting

Proof of concept of distributed rate limiting multiple workers processing speed.

Rate limiting follows a leaky bucket algorithim. The bucket is implemented using a speical token-bucket queue. Max size of the bucket is enforced by using the max length of a token queue. The bucket is refilled by a single worker, which also is responsible for the refill rate.

Workers must get a token before fetching and processing any tasks.

@hkucuk
hkucuk / pywebview_flask_sample.py
Created July 16, 2019 20:07
PyWebView Flask Sample
from flask import Flask
import webview
import sys
import threading
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@Birdi7
Birdi7 / callback_data_factory_simple.py
Last active October 29, 2024 18:25
A simple example of usage of callback data factory from aiogram
"""
This is a simple example of usage of CallbackData factory
For more comprehensive example see callback_data_factory.py
"""
import asyncio
import logging
from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
@kapad
kapad / toggle-nightlight.sh
Created July 3, 2018 20:30
Script to toggle the Gnome nightlight setting.
#!/bin/bash
setting=$(gsettings get org.gnome.settings-daemon.plugins.color night-light-enabled)
if [[ $setting == "true" ]]; then
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false
else
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
fi
@tolunayozturk
tolunayozturk / VSCodeNautilusExt.py
Last active January 19, 2022 20:06
"Open in VSCode" extension for Nautilus
# -*- coding: latin-1 -*-
# Copy this python script under ~/.local/share/nautilus-python/extensions and restart nautilus.
# You may need to create nautilus-python and extensions folders if they do not exist. –
import os
import gi
gi.require_version('Nautilus', '3.0')
from gi.repository import Nautilus, GObject
@tysonholub
tysonholub / windows.py
Last active January 4, 2022 19:04
Elementary OS: Switch windows of the same application
from subprocess import Popen, PIPE, call
import logging
import logging.handlers
import sys
import os
# NOTE: this script assumes a debian system and requires the wmctrl and xdotool packages
# sudo apt-get install wmctrl xdotool
# NOTE: To get [Alt + ` ]to register on Elementary OS requires removing the keybinding via dconf editor for switch-group/switch-group-backward
@mattbennett
mattbennett / client.py
Created April 14, 2017 15:00
Nameko Auth Toy
from nameko.standalone.rpc import ClusterRpcProxy
config = {
'AMQP_URI': 'amqp://guest:guest@localhost:5672/'
}
with ClusterRpcProxy(config) as rpc:
session_token = rpc.auth.login("admin", "secret")
with ClusterRpcProxy(config, context_data={'session': session_token}) as rpc:
@mitnk
mitnk / history_couchdb.py
Last active May 15, 2025 14:53
xonsh history backend with couchdb
"""
xonsh history backend with couchdb.
Copy this file to "~/.xonsh/history_couchdb.py" and put the following
into your "~/.xonshrc" file.
import os.path
import sys
xonsh_ext_dir = os.path.expanduser('~/.xonsh')
if os.path.isdir(xonsh_ext_dir):