Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# parse-usb-devices.sh
#
# Parse the output of the "usb-devices" bash script and filter
# only for Mass Storage devices (Class 08). Include the active
# device speed (to see whether it is USB2 or USB3.
set -e
import logging
import ssl
import uuid
from urllib.parse import urlparse
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from django.db import models
from django.utils.functional import cached_property
#!/usr/bin/env python3
import ipaddress
from SPF2IP import SPF2IP
ignore_list = set({'127.0.0.1/32'})
ignore_list.update({ # Microsoft O365
'40.92.0.0/15',
import asyncio
import uvicorn
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import HTMLResponse
from starlette.routing import Route
from sse_starlette.sse import EventSourceResponse, unpatch_uvicorn_signal_handler
# unpatch_uvicorn_signal_handler() # if you want to rollback monkeypatching of uvcorn signal-handler
from queue import Queue
from collections import defaultdict
class Publisher(object):
"""
Contains a list of subscribers that can can receive updates.
Each subscriber can have its own private data and may subscribe to
different channel.
"""
@app.get("/sse/stream")
async def stream(req: Request, channel: str = "default", redis: Redis = Depends(depends_redis)):
# return EventSourceResponse(subscribe(channel, redis))
async def event_publisher():
_log.info(f"Subscribing for client {req.client}")
(channel_subscription,) = await redis.subscribe(channel=Channel(channel, False))
try:
#!/bin/bash
# don't use this if all your need is a route that goes through your ISP router
# instead of an openvpn tunnel. OpenVPN has this as a built-in feature!
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi