Skip to content

Instantly share code, notes, and snippets.

@Moaneschien
Moaneschien / goertzel.nim
Last active November 13, 2023 11:14
Compare sine wave oscillators for speed and accuracy. Goertzel, Rotating Vector vs. sin()
#nim.cfg
#-d:release
#-d:danger
#-d:samplerate=44100
# Result (12th Gen Intel(R) Core(TM) i9-12900 2.40 GHz):
#
#GSinOsc : (seconds: 0, nanosecond: 283590800)
#RVSinOsc : (seconds: 1, nanosecond: 615131700)
#STDSinOsc: (seconds: 6, nanosecond: 88408100)
@ingoogni
ingoogni / hbmqttcherrypy.py
Last active March 6, 2019 06:16
Cherrypy MQTT HBMQTT plugin
#https://stackoverflow.com/questions/26270681/can-an-asyncio-event-loop-run-in-the-background-without-suspending-the-python-in
import asyncio
import threading
import cherrypy
from cherrypy.process import plugins
from hbmqtt.client import MQTTClient, ClientException
from hbmqtt.mqtt.constants import QOS_1, QOS_2
@ingoogni
ingoogni / CherryPy_PGrepub.py
Last active October 1, 2017 16:54
CherryPy PostgreSQL pgpubsub
import threading
import pgpubsub
import cherrypy
from cherrypy.process import plugins
class PGrepub(plugins.SimplePlugin):
"""
Plugin that listens to Postresql notification channels and publishes
the payload unmodified to a channel on the CherryPy bus.
@ingoogni
ingoogni / cherrypy_SSE.py
Last active June 6, 2024 17:17
CherryPy SSE / Server-Sent Events, Eventsource helpers to publish data from cherrypy's pub/sub bus
import threading
import cherrypy
from cherrypy.process import plugins
class Portier(threading.Thread):
"""
The Doorman (Portier) detects changes of message by listening to the
subscribed channel, opens 'the door' as a message appears, yield it
and closes the door once trough.