Skip to content

Instantly share code, notes, and snippets.

View kylemanna's full-sized avatar

Kyle Manna kylemanna

View GitHub Profile
esphome:
name: esp_tdisplay
platform: ESP32
board: featheresp32
wifi:
ssid: "some ssid"
password: "wifipassword"
# Enable fallback hotspot (captive portal) in case wifi connection fails
@kylemanna
kylemanna / abandon-threads.py
Last active June 25, 2020 16:41
Do you _need_ to call threading.Thread.join() to clean-up threads on python if they exit cleanly?
#!/usr/bin/env python3
"""Do you _need_ to call threading.Thread.join() to clean-up threads on python if they exit cleanly?
"""
import threading
import time
def do_a_thing(idx):
print(f"starting {idx}")
time.sleep(1)
@kylemanna
kylemanna / python-fix-zipinfo-1980.py
Created June 24, 2020 23:16
Monkey patch to fix ValueError('ZIP does not support timestamps before 1980')
class ZipInfoTimeless(zipfile.ZipInfo):
def __init__(self, *args, **kwargs):
# Patch year to 1980 if given a datetime before 1980. Also jump through hoops because tuples are
# immutable.
if 'date_time' in kwargs and kwargs['date_time'][0] < 1980:
dt = list(kwargs['date_time'])
dt[0] = 1980
kwargs['date_time'] = tuple(dt)
elif len(args) > 1 and args[1][0] < 1980:
dt = list(args[1])
@kylemanna
kylemanna / 00_README.md
Last active June 19, 2020 17:27
Why does this KingWin KWCR-801U3 USB3 Card reader generate block_rq_complete errors when sitting idle on kernel 5.7.2-arch1-1?

Khada's Tone Board DAC via XMOS USB

https://www.khadas.com/tone

Contents of card directory files under /proc/asound for reference.

File id

Control
@kylemanna
kylemanna / falcon-zipfile-stream.py
Created May 16, 2020 00:08
Falcon + zipfile streaming proof of concept v2
#!/usr/bin/env python3
#
# Falcon + zipfile streaming content using os.pipe() to minimize RAM usage to a
# pipes worth of data.
#
# This test program generated a nearly 500 MB zip file with various compression
# arguments supported by the python3 standard library.
#
# Usage for debug webserver:
# $ ./app.py
# Run this tool and feed it stuff.
# $ python3 udp-test.py
#
# Emulate a remote client sending data:
# $ cat /dev/urandom | nc -u 127.0.0.1 7502
#
# Cancel netcat and try again, second attempt will fail because the source port
# likely changed (not guaranteed, but statistically likely)
#
#
# Proof of Concept
#
# Compose a docker image of an upstream images so that binaries packages in one
# image can be incorporated into another.
#
# TODO This copies, would be nice if there was a way to attach an image to a
# container like `docker run --volumes-from` does for containers.
# These FROMs used as a way to distribute files via an image
#include <iostream>
#include <cxxabi.h>
using namespace std;
// To execute C++, please define "int main()"
int main() {
auto words = { "Hello, ", "World!", "\n" };
int status;