Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
Slowly advancing on hobby projects

Michel Albert exhuma

🐢
Slowly advancing on hobby projects
View GitHub Profile
@exhuma
exhuma / README.md
Last active Mar 21, 2021
howler example
View README.md

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 Dec 31, 2020
Project Description
View PROJECTS.rst

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 Sep 26, 2020
Test-Harness for SQLAlchemy unit-tests
View harness.py
"""
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 Aug 21, 2020
WSGI middleware setting up a queue log handler
View lsmw.py
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 Jul 16, 2020
SA relationship updates
View example.py
class ScannedPort:
label: str = ""
clsas ScannedDevice:
hostname: str = ""
ports: List[ScannedPort] = []
class Port(Base):
hostname = Column(String, ForeignKey("Device.hostname")
label = Column(String)
@exhuma
exhuma / iptypes.py
Created May 8, 2020
SQLAlchemy types for PostgreSQL inet types
View iptypes.py
"""
This module defines additional "IP-Address" type decorators for use with
SQLAlchemy and PostgreSQL. These types will convert the PostgreSQL values
to/from Python :py:mod:`ipaddress` classes.
These classes can be used in model definitions::
class MyTable(Base):
...
ip = Column(PgIpAddress, ...)
@exhuma
exhuma / fetchedvalue.py
Created Mar 5, 2020
SQLAlchemy demonstration of the "FetchedValue" feature
View fetchedvalue.py
"""
This file demonstrated using the "FetchedValue" feature of SQLAlchemy for
values which are generated by the DB, without knowing *how* they are generated
in the DB.
"""
from sqlalchemy import Column, DateTime, FetchedValue, Unicode, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
View mandelbrot.py
# pylint: disable=no-member, no-name-in-module
"""
This program is inspired on exercise 4.4 from the book for 1CB "CNESC
Informatique" (2019-2020): The Mandelbrot set. The exercise demands the
following features:
* Display the Mandelbrot set on the complex plane. Initially between -2.2-1.2j
and 1.0+1.2j and later by coordinates selected by the user (see below).
* Points within the set should be drawn in black, points outside of the set
should be colored based on the number of iterations necessary to determine
@exhuma
exhuma / read_prices.py
Created Oct 2, 2019
Scrape Prices from a Web-Page
View read_prices.py
"""
This module shows an alternative implementation of the code shown in the SO question
https://stackoverflow.com/questions/58188342/looping-through-web-pages
Comments marked with a ♫ symbol are possible improvements to this code which were
left out to keep concepts out of the code which could make it more difficult to
understand for beginners.
"""
from os.path import exists
@exhuma
exhuma / accept.py
Created Aug 8, 2019
Parser for the "Accept" header in HTTP requests
View accept.py
"""
This module contains helpers to work with the "Accept" request header
"""
import re
from typing import Generator, Iterable, List, NamedTuple, Tuple
AcceptType = NamedTuple('AcceptType', [
('media_type', str),
('quality', float),
])