Skip to content

Instantly share code, notes, and snippets.

View KubaO's full-sized avatar

Kuba Sunderland-Ober KubaO

View GitHub Profile
@KubaO
KubaO / winmsgasyncio.py
Last active September 10, 2024 12:25
Python 3.12 asyncio ProactorEventLoop integration with Windows message pump / event loop and tkinter event loop
"""
An event loop policy that integrates Windows message loop with IOCP-based async processing.
Usage:
asyncio.set_event_loop_policy(winmsgasyncio.MsgProactorEventLoopPolicy())
To integerate with tkinter, use tk_sync_mainloop(root) or await tk_async_mainloop(root).
"""
# SPDX-License-Identifier: MIT
@KubaO
KubaO / autopep8.py
Last active September 9, 2024 13:21
A bare-bone Thonny AutoPep8 extension.
import autopep8
from thonny import get_workbench
from tkinter.messagebox import showinfo
DEBUG = False
# Save to:
# %APPDATA%\Roaming\Thonny\plugins\Python3.10\site-packages\thonnycontrib\autopep8.py
# references:
@KubaO
KubaO / README.md
Created January 31, 2024 21:51
EE.SO KiCad

This is a place for KiCad layouts/schematics for electronics.stackexchange.com.

There are many ways of solving such circuits. For people who looked at lots of logic diagrams like these - they'll identify them pretty much just by looking at them for a minute. For someone who's just learning it for the first time, it helps to have a process. Here are the steps I'd take. You don't need to take those exact steps, of course!

  1. Replace the input lines with labels:

schematic

@KubaO
KubaO / 4-20mA single.kicad_sch
Last active March 5, 2023 05:35
4-20mA Converter EE SO
(kicad_sch (version 20211123) (generator eeschema)
(uuid 1a16158f-96b7-446e-9b07-fa7168bd0f9f)
(paper "A")
(title_block
(title "4-20mA circuit IC troubleshooting")
(date "2023-03-04")
)
@KubaO
KubaO / rm-replace-refs.sh
Last active August 24, 2021 16:00
Remove all replace refs in git
# /bin/bash
# This removes all replace refs in the current repo, after logging them.
set -e
cmd=$(basename "$0")
logfile="~/.${cmd}.log.txt"
tmpfile=$(mktemp "${TMPDIR}/.${cmd}")
origin=$(git config --get remote.origin.url)
echo "# $(date) BEGIN ${origin}" >> "${logfile}"
// complete compileable example begins
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
@KubaO
KubaO / coltextread.m
Last active February 16, 2018 14:02
An Octave universal delimited file cell reader.
## Author: voithos on so
## Url: https://stackoverflow.com/a/8319848/1329652
function varargout = coltextread(fname, delim)
% Initialize the variable output argument
varargout = cell(nargout, 1);
% Initialize elements of the cell array to nested cell arrays
% This syntax is due to {:} producing a comma-separated
[varargout{:}] = deal(cell());