Skip to content

Instantly share code, notes, and snippets.

@mathieu-b
mathieu-b / CH340_Ubuntu_22.04_setup.md
Last active September 26, 2024 07:18
CH340 Setup on Ubuntu 22.04 LTS (with required fixes)

The CH340 Drivers already come with the OS:

λ lsmod | grep -i ch34
ch341                  24576  0
usbserial              69632  3 usb_wwan,ch341,option

When connecting the CH340 device, at first it is recognized, but it will then be automatically disconneted after a short while:

@Morreski
Morreski / timed_cache.py
Last active September 3, 2024 00:29
Python lru_cache with timeout
from datetime import datetime, timedelta
import functools
def timed_cache(**timedelta_kwargs):
def _wrapper(f):
update_delta = timedelta(**timedelta_kwargs)
next_update = datetime.utcnow() + update_delta
# Apply @lru_cache to f with no cache size limit
@eberle1080
eberle1080 / module_watcher.py
Created June 7, 2011 20:50
Automatically reload python module / package on file change
#!/usr/bin/env python
# Author: Chris Eberle <[email protected]>
# Watch for any changes in a module or package, and reload it automatically
import pyinotify
import imp
import os
class ModuleWatcher(pyinotify.ProcessEvent):
"""