Skip to content

Instantly share code, notes, and snippets.

View daed's full-sized avatar

Brad Arnett daed

View GitHub Profile
### Keybase proof
I hereby claim:
* I am daed on github.
* I am erudyne (https://keybase.io/erudyne) on keybase.
* I have a public key ASCbVAUsaUvoDuYQBU4zyFqTch7E7ftTRWidZFrM9WHuxwo
To claim this, I am signing this object:
@daed
daed / uasyncio.md
Last active November 6, 2023 01:13
micropython uasyncio and concurrency

A study of concurrency

Brad Arnett

Assumptions

The following are technical assumptions that are made for the context of this document. The information in this document might not be valid outside of the below:

  • The target microcontroller is the Raspberry Pi Pico W
  • You're using the Micropython version 1.20 or later
@daed
daed / dict.py
Created June 3, 2024 06:06
base class for dict-like behavior
"""dict.py
Baseclass for Dict-Like Behavior
This module provides a baseclass for dict-like behavior. It is intended to be
used as a baseclass for classes that need to behave like dictionaries, but
require additional functionality or customization.
Example:
@daed
daed / collection.py
Created June 3, 2024 06:08
generic Collection class for use with Dicts
import os
from src.lib.models.dict import Dict
class Collection(Dict):
"""
A generic collection class that extends the Dict class. This class is not persistent and
data inside it will not survive a server restart. It is meant to be used for in-memory data objects only.
Attributes:
name (str): The name of the collection.
@daed
daed / logger.py
Created June 3, 2024 06:20
a customized general purpose logger
import os
import logging
class CustomFormatter(logging.Formatter):
"""Logging Formatter to add colors, count warning/errors, and use relative paths
This class is a custom logging formatter that adds color to the log messages
based on the log level. It also counts the number of warnings and errors
and adds that to the log message. It also modifies the pathname to show
a relative path instead of an absolute path.
@daed
daed / mongo_collection.py
Created June 3, 2024 06:31
a general collection that integrates with mongodb
"""mongo_collection.py: A generic collection class for MongoDB."""
import os
from bson import ObjectId
DB_NAME = "mud"
class Collection:
"""
A generic MongoDB collection class.