Skip to content

Instantly share code, notes, and snippets.

View koi8-r's full-sized avatar
🐧

Valentin Nagornyy koi8-r

🐧
View GitHub Profile
Add
scrub on bridge100 all min-ttl 65
to
'/etc/pf.conf'
Reload with
sudo pfctl -f /etc/pf.conf
Check with
sudo pfctl -sa
task = asyncio.create_task(read_output())
handler = event_loop().call_later(2, cancel_asyncio_task, task)
task.add_done_callback(lambda _: handler.cancel())
await task
@koi8-r
koi8-r / shelly_plug_s.py
Created January 30, 2023 11:59
Shelly-Plug-S API Example: The Squid game
import logging
from base64 import b64encode
from json import loads as jsdecode
from urllib.parse import urlencode
from enum import Enum
from http.client import HTTPConnection
from time import sleep
from random import uniform
from typing import Union
from inspect import Parameter, signature
from typing import Any, Optional
def fn(i: int, z: Optional[str] = None, *a, v: int = -1, **kw: Any):
pass
if __name__ == '__main__':
p = signature(fn).parameters
def lock(res):
pass
def free(res):
pass
class MyCtx(object):
__slots__ = ('res',)
@koi8-r
koi8-r / docker-swarm-ports.md
Created October 22, 2020 11:00 — forked from BretFisher/docker-swarm-ports.md
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

from aiohttp import web, ClientSession as UA
import asyncio as A
import sys, os
def update(data: bytes):
path = __file__
with open(path, mode='wb') as f:
f.write(data)
print('Updated')
@koi8-r
koi8-r / MyPy.py
Created May 3, 2020 18:19
Python MyPy cheats
from typing import Any, TypeVar, Callable, IO, Match
import re, sys
F = TypeVar('F', bound=Callable[..., Any])
def decorator(fn: F) -> F:
...
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class Product(object):
url: str
def __getattribute__(self, name):
ret = object.__getattribute__(self, name)
if isinstance(ret, property):
return ret.__get__(self)
return ret
val = None