This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Custom PlatformIO filter for parsing Rd-03E radar sensor data from UART. | |
This filter is designed to process UART frames from the Rd-03E gesture recognition radar sensor. | |
It extracts distance and gesture information from the sensor's output and formats it for easy reading. | |
Usage: | |
1. Place this file in the `monitor` directory of your PlatformIO project as `filter_rd03e.py` | |
2. Run the PlatformIO device monitor with the filter enabled: | |
`platformio device monitor -b 256000 -p /dev/ttyUSB0 -f rd03e` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try it out by opening https://ide.kaitai.io/ and copying this file there | |
# Based on an article by @angelcarve about ESP8266 binary image parsing with Kaitai Struct: | |
# https://carvesystems.com/news/parsing-binaries-with-kaitai-struct/ | |
meta: | |
id: esp8266 | |
file-extension: bin | |
endian: le | |
seq: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_monthly_payment( | |
*, | |
loan: float | int | str | Decimal, | |
annual_interest_rate: float | str | Decimal, | |
years: int | None = None, | |
months: int | None = None, | |
): | |
""" | |
Calculates the annuity monthly mortgage payment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rate_limit_per_second(rate: int): | |
last_request = time.time() | |
lock = asyncio.Lock() | |
@contextlib.asynccontextmanager | |
async def rate_limiter(): | |
nonlocal last_request, lock | |
async with lock: | |
now = time.time() | |
elapsed = now - last_request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""xml2json.py Convert XML to JSON | |
Relies on ElementTree for the XML parsing. This is based on | |
pesterfish.py but uses a different XML->JSON mapping. | |
The XML->JSON mapping is described at | |
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html | |
Rewritten to a command line utility by Hay Kranen < github.com/hay > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
avahi-browse -rt _ipp._tcp | |
avahi-browse -rt _uscan._tcp | |
driverless | |
lpadmin -p PRINTER_NAME -v "result_of_driverless" -E -m everywhere |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
services: | |
- docker:dind | |
stages: | |
- build | |
- integration | |
- dev-release | |
- prod-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://gitlab.com/-/snippets/1890428 | |
-- The query shows "the forest of trees" of blocked and blocking sessions with the corresponding queries. It helps to understand, which session is being blocked by which one, and what is "the depth" of the lock chain. | |
-- Use it to find the "roots" of trees, then use pg_cancel_backend(pid) or pg_terminate_backend(pid) to get rid of blockers and release the locks. | |
-- Derived from DataEgret's locktree.sql (https://github.com/dataegret/pg-utils/blob/master/sql/locktree.sql) | |
\timing on | |
set statement_timeout to '2s'; | |
with recursive l as ( | |
select |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
NEXT = object() | |
class new_pipeline: | |
def __init__(self): | |
self._coroutines = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Script for sorting classes by type in annotation. It may be usefull for code refactoring after code generation. | |
For example: | |
``` | |
class C: | |
a: Optional[A] = None | |
b: Optional[B] = None |
NewerOlder