Skip to content

Instantly share code, notes, and snippets.

@kylekyle
kylekyle / pool.py
Created March 22, 2022 01:30
A full example of a producer/consumer using process pools in python
from threading import Event
from time import sleep
from traceback import print_exception
from multiprocessing import Pool, Manager
from queue import Full
from signal import signal, SIGTERM, SIGINT
class Consumer1:
def __init__(self):
print("Initializing Consumer1 ...")
@kylekyle
kylekyle / Generic Object Detection.ipynb
Last active March 5, 2022 19:04
Minimal example of cropping and drawing bounding boxes around objects in images.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylekyle
kylekyle / disk.js
Last active January 15, 2021 05:36
Disk game proof-of-concept
// http://maxwellito.github.io/vivus/
// animate the appearance / disappearance?
// eight static
// two - opposite direction
// three in a circle
// randomly moving clickers
// shrinking / growing
import { SVG, easing, List, Runner, Timeline } from '@svgdotjs/svg.js'
import '@svgdotjs/svg.topath.js' // might need spinning disks
@kylekyle
kylekyle / sshuttle-openwrt.md
Last active December 16, 2023 10:47
Install and configure sshuttle on OpenWrt

Install and configure sshuttle on OpenWrt

Note that ANY flash update will wreck the extroot configuration. I didn't realize that and had to:

Configure extroot

@kylekyle
kylekyle / mmi-csv.userscript.js
Created November 12, 2020 02:12
Tampermonkey script to add buttons for downloading MMI results as CSV
// ==UserScript==
// @name MMI CSV
// @namespace K-Dizzle
// @version 1.0
// @description Adds a button to download MMI results as a CSV
// @author K-Dizze
// @match https://mmi.run/*
// @grant none
// @require https://cdn.jsdelivr.net/gh/uzairfarooq/arrive/minified/arrive.min.js
// ==/UserScript==
@kylekyle
kylekyle / ChangeForm.html
Last active September 6, 2020 20:59
Use Google Forms as an Electronic Medical Record system :-)
<style>
* {
font-family: Roboto;
}
li {
margin: 5px 0;
}
</style>
@kylekyle
kylekyle / iarrive.js
Created August 16, 2020 01:21
Uses MutationsObservers and IntersectingObservers to let you know when elements arrive or appear.
"use strict";
var arriveUniqueId = 0;
var utils = (function() {
var matches = HTMLElement.prototype.matches
|| HTMLElement.prototype.webkitMatchesSelector
|| HTMLElement.prototype.mozMatchesSelector
|| HTMLElement.prototype.msMatchesSelector;
return {
@kylekyle
kylekyle / washing_machine_monitor.js
Created July 2, 2020 20:13
Monitor when an appliance turns on/off using a Tuya compatible (Smart Life and a bunch of other brands) smart plug
const axios = require('axios')
const TuyAPI = require('tuyapi');
var connected = false;
var washerWasOn = false;
// follow these instructions to get the key and id for your plug:
// https://github.com/AMoo-Miki/homebridge-tuya-lan/wiki/Setup-Instructions
const washer = new TuyAPI({
id: 'YOUR ID',
@kylekyle
kylekyle / garageDoor.c
Last active June 20, 2020 20:38
Control a garage door with a Raspberry Pi and Echo
// A script that runs a raspberry pi to receive commands from an echo
// and control a garage door opener wired to the GPIO
// To set up the Echo, follow this guide:
// https://read.acloud.guru/how-to-build-your-own-alexa-voice-activated-iot-smart-lamp-for-less-than-35-9820ccd07516
// To compile this script, use the Makefile in the subscribe_publish_sample of the AWS IoT Device SDK. You'll
// need to link in the wiringPi library.
// If you are having policy issues, you can create a super-permissive policy that will let your device do anything:
@kylekyle
kylekyle / style_transfer.py
Last active May 20, 2020 00:42
Large resolution style transfer
# -*- coding: utf-8 -*-
# style_transfer.py <content> <style>
# CUDA_VISIBLE_DEVICES=3 python style_transfer.py walk.jpg kandinsky.jpg
import sys
content_path = sys.argv[1]
style_path = sys.argv[2]
max_dim = 1024
total_variation_weight=30