Skip to content

Instantly share code, notes, and snippets.

View exhuma's full-sized avatar
🐢
Slowly advancing on hobby projects

Michel Albert exhuma

🐢
Slowly advancing on hobby projects
View GitHub Profile
"""
This module contains classes that dispatch calls depending on arg-types.
The goal is to handle "media-types" for HTTP APIs with well-defined functions.
An "incoming" request may contain a payload that needs to be stored in the
back-end. We need to "parse/decode" the incoming object depending on media-type.
Similarly, when we respond to the request we may need to convert the object to
something the client understands. The client can opt-in/-out using the "Accept"
media-type.
#!/bin/bash
# -----------------------------------------------------------------------------
# This script extracts the path of the devcontainer config-file from
# docker-events.
#
# This helps in identifying who has started a container if the container-name
# does not itself include any indication.
#
# This can be used to determine if a container can be safely stopped/removed
@exhuma
exhuma / example.py
Last active April 14, 2024 10:25
Automatic Pagination with FastAPI and SQLAlchemy
from fastapi import Depends, FastAPI
from pydantic import BaseModel
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Query, Session
from pagination import PaginatedList, paginated_get
Base = declarative_base()
@exhuma
exhuma / settings.json
Created November 28, 2023 15:29
Don't auto-format SQL files in VS-Code
{
"[sql]": {
"editor.formatOnSave": false
}
}
@exhuma
exhuma / valuable_items.mermaid
Last active September 10, 2022 20:31
No Man's Sky -- Valuable Items Construcion / Requirements Tree
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@exhuma
exhuma / README.md
Last active March 21, 2021 12:41
howler example

Example on how to use howler.js

This requires howler.js to be in the same folder as all these files. It can be found in the dist folder of the howler.js download.

@exhuma
exhuma / PROJECTS.rst
Last active December 31, 2020 10:28
Project Description

Projects I maintain on stream

Stream URL: https://twitch.tv/exhuma

Current Focus: "WickedShout"
Secondary: "x690", "melldechof"

Some days I may work on other project from my GitHub repositories for general housekeeping.

@exhuma
exhuma / harness.py
Last active September 26, 2020 10:16
Test-Harness for SQLAlchemy unit-tests
"""
Helper functions for unit-testing with SQLAlchemy
This provides a context-manager "rb_session" which
creates a new session that ignores all ".commit()"
calls. This might not work with all databases. It
has been tested with PostgreSQL. Verify that the
commits are really ignored if you use any other DB.
"""
@exhuma
exhuma / lsmw.py
Last active August 21, 2020 05:32
WSGI middleware setting up a queue log handler
import logging
import sys
from logging.handlers import QueueHandler, QueueListener
from queue import Queue
from time import sleep
class FlushingHandler(QueueHandler):
def flush(self):
super().flush()
@exhuma
exhuma / example.py
Created July 16, 2020 08:39
SA relationship updates
class ScannedPort:
label: str = ""
clsas ScannedDevice:
hostname: str = ""
ports: List[ScannedPort] = []
class Port(Base):
hostname = Column(String, ForeignKey("Device.hostname")
label = Column(String)