Skip to content

Instantly share code, notes, and snippets.

View wybiral's full-sized avatar

davy wybiral wybiral

View GitHub Profile
@wybiral
wybiral / mastodon_watch.py
Created February 17, 2023 18:23
Watch Mastodon stream for notifications and blink Thingy52 LED
'''
Watch Mastodon stream for notifications and blink Thingy52
'''
import asyncio
import os
import ssl
try:
import certifi
from argparse import ArgumentParser
from time import sleep
try:
import twitter
except:
print('Requires python-twitter: pip install python-twitter')
exit(1)
api = twitter.Api(
consumer_key='...',
from time import sleep
try:
from twitter import Api
import twitter
except:
print('Requires python-twitter: pip install python-twitter')
exit(1)
api = Api(
consumer_key='...',
from time import sleep
try:
from twitter import Api
except:
print('Requires python-twitter: pip install python-twitter')
exit(1)
api = Api(
consumer_key='CONSUMER_KEY_HERE',
consumer_secret='CONSUMER_SECRET_HERE',
import asyncio
import zipfile
from io import BytesIO
async def handler(r, w):
line = await r.readline()
try:
method, path, version = line.split(b' ', 2)
except:
w.close()
import asyncio
import zipfile
from io import BytesIO
async def handler(r, w):
line = await r.readline()
try:
method, path, version = line.split(b' ', 2)
except:
w.close()
import asyncio
# next client id
client = 1
async def handler(r, w):
line = await r.readline()
try:
method, path, version = line.split(b' ', 2)
except:
// Defaults:
// Bw = 125 kHz
// Cr = 4/5
// Sf = 128chips/symbol
// CRC on
RH_RF95::ModemConfig modem = {0x72, 0x74, 0x00};
void setBandwidth(uint32_t bw) {
uint8_t index;
uint32_t bandwidths[] = {
@wybiral
wybiral / main.py
Created July 12, 2021 18:33
MicroPython Server-Sent Events
import network
import web
import uasyncio as asyncio
CLIENTS = set()
# access point credentials
AP_SSID = 'SSE AP'
AP_PASSWORD = 'donthackmebro'
AP_AUTHMODE = network.AUTH_WPA_WPA2_PSK
@wybiral
wybiral / httpversion.py
Created April 4, 2021 18:25
Test different HTTP version lines against a list of addresses
from socket import create_connection
from ssl import create_default_context
def run_test(addr, path, httpversion):
host, port = addr
ctx = create_default_context()
with create_connection(addr) as s:
with ctx.wrap_socket(s, server_hostname=host) as ss:
ss.send(b'GET %s %s\r\n' % (
path.encode('utf8'),