Skip to content

Instantly share code, notes, and snippets.

@asafc
asafc / opalogger.py
Created July 8, 2021 21:16
Example fastapi server that accept OPA decision logs and prints them to the console
"""
you may run this example with uvicorn, by using this command:
uvicorn opalogger:app --reload
"""
import gzip
from typing import Callable, List
from fastapi import Body, FastAPI, Request, Response
@asafc
asafc / docker-compose.yml
Created July 8, 2021 20:57
OPAL example configuration with decision logs
version: "3.8"
services:
# When scaling the opal-server to multiple nodes and/or multiple workers, we use
# a *broadcast* channel to sync between all the instances of opal-server.
# Under the hood, this channel is implemented by encode/broadcaster (see link below).
# At the moment, the broadcast channel can be either: postgresdb, redis or kafka.
# The format of the broadcaster URI string (the one we pass to opal server as `OPAL_BROADCAST_URI`) is specified here:
# https://github.com/encode/broadcaster#available-backends
broadcast_channel:
image: postgres:alpine
@asafc
asafc / yunmai_protocol.txt
Created February 27, 2019 00:24 — forked from pwnall/yunmai_protocol.txt
Yunmai smart scale (M1301, M1302, M1303) Bluetooth LE protocol notes
Yunmai smart scale (M1301, M1302, M1303) Bluetooth LE protocol notes
Commands are written to GATT attribute 0xffe9 of service 0xffe5. Responses come
as value change notifications for GATT attribute 0xffe4 of service 0xffe0. These
are 16-bit Bluetooth LE UUIDs, so nnnn is 0000nnnn-0000-1000-8000-00805F9B34FB.
-----
Packet Structure